dgl.transform.laplacian_lambda_max

dgl.transform.laplacian_lambda_max(g)[source]

Return the largest eigenvalue of the normalized symmetric laplacian of g.

The eigenvalue of the normalized symmetric of any graph is less than or equal to 2, ref: https://en.wikipedia.org/wiki/Laplacian_matrix#Properties

Parameters:g (DGLGraph or BatchedDGLGraph) – The input graph, it should be an undirected graph.
Returns:
  • If the input g is a DGLGraph, the returned value would be a list with one element, indicating the largest eigenvalue of g.
  • If the input g is a BatchedDGLGraph, the returned value would be a list, where the i-th item indicates the largest eigenvalue of i-th graph in g.
Return type:list

Examples

>>> import dgl
>>> g = dgl.DGLGraph()
>>> g.add_nodes(5)
>>> g.add_edges([0, 1, 2, 3, 4, 0, 1, 2, 3, 4], [1, 2, 3, 4, 0, 4, 0, 1, 2, 3])
>>> dgl.laplacian_lambda_max(g)
[1.809016994374948]