graph_tool.spectral#

This module contains several linear operators based on network structure, which are useful for spectral analysis.

Sparse matrices#

adjacency

Return the adjacency matrix of the graph.

laplacian

Return the Laplacian (or Bethe Hessian if \(r > 1\)) matrix of the graph.

incidence

Return the incidence matrix of the graph.

transition

Return the transition matrix of the graph.

modularity_matrix

Return the modularity matrix of the graph.

hashimoto

Return the Hashimoto (or non-backtracking) matrix of a graph.

magnetic_laplacian

Return the magnetic Laplacian matrix of the graph.

directed_laplacian

Return the directed Laplacian matrix of Chung.

Operator objects#

AdjacencyOperator

A scipy.sparse.linalg.LinearOperator representing the adjacency matrix of a graph.

LaplacianOperator

A scipy.sparse.linalg.LinearOperator representing the laplacian matrix of a graph.

IncidenceOperator

A scipy.sparse.linalg.LinearOperator representing the incidence matrix of a graph.

TransitionOperator

A scipy.sparse.linalg.LinearOperator representing the transition matrix of a graph.

HashimotoOperator

A scipy.sparse.linalg.LinearOperator representing the hashimoto matrix of a graph.

CompactHashimotoOperator

A scipy.sparse.linalg.LinearOperator representing the compact hashimoto matrix of a graph.

MagneticLaplacianOperator

A scipy.sparse.linalg.LinearOperator representing the magnetic Laplacian matrix of a graph.

DirectedLaplacianOperator

A scipy.sparse.linalg.LinearOperator representing the directed Laplacian of a graph.

Spectral properties#

algebraic_connectivity

Return the algebraic connectivity of the graph, i.e. the second smallest eigenvalue of its Laplacian.

spectral_embedding

Return a spectral embedding of the vertices, given by the eigenvectors of the Laplacian (Laplacian eigenmaps) or of the adjacency matrix.

spectral_clustering

Partition the vertices with spectral clustering.

num_spanning_trees

Return the number of spanning trees of an undirected graph.

dim_select

Select the number of dimensions from a sequence of eigenvalues or singular values, with the profile likelihood method of Zhu and Ghodsi.