Documentation
MotifCluster.build_motif_adjacency_matrix — MethodBuild a motif adjacency matrix from an adjacency matrix. Entry (i, j) of a motif adjacency matrix is the sum of the weights of all motifs containing both nodes i and j.
MotifCluster.a_b_one — MethodCompute a * (b @ ones) where a, b, ones are square matrices of the same size, and ones contains all entries equal to one. The product * is an entry-wise (Hadamard) product, while @ represents matrix multiplication. This method is more efficient than the naive approach when a or b are sparse.
MotifCluster.a_one_b — MethodCompute a .* (ones * b) where a, b, ones are square matrices of the same size, and ones contains all entries equal to one.
MotifCluster.dropzeros_killdiag — MethodSet diagonal entries to zero and sparsify.
MotifCluster.get_largest_component — MethodGet the indices of the vertices in the largest connected component of a graph from its adjacency matrix.
MotifCluster.get_motif_names — MethodGet the names of some common motifs as strings.
MotifCluster.build_G — MethodBuild the adjacency matrix G.
MotifCluster.build_Gd — MethodBuild the double-edge adjacency matrix Gd.
MotifCluster.build_Gp — MethodBuild the product matrix Gp.
MotifCluster.build_Gs — MethodBuild the single-edge adjacency matrix Gs.
MotifCluster.build_Id — MethodBuild the identity matrix Id.
MotifCluster.build_J — MethodBuild the directed indicator matrix J.
MotifCluster.build_J0 — MethodBuild the missing-edge indicator matrix J0.
MotifCluster.build_Jd — MethodBuild the double-edge indicator matrix Jd.
MotifCluster.build_Je — MethodBuild the edge-and-diagonal matrix Ie.
MotifCluster.build_Jn — MethodBuild the vertex-distinct indicator matrix Jn.
MotifCluster.build_Js — MethodBuild the single-edge indicator matrix Js.
MotifCluster.build_laplacian — MethodBuild a Laplacian matrix (combinatorial Laplacian or random-walk Laplacian) from a symmetric (weighted) graph adjacency matrix.
MotifCluster.get_first_eigs — MethodCompute the first few eigenvalues by magnitude and associated eigenvectors of a matrix.
MotifCluster.run_laplace_embedding — MethodRun Laplace embedding on a symmetric (weighted) adjacency matrix with a specified number of eigenvalues and eigenvectors.
MotifCluster.run_motif_embedding — MethodCalculate a motif adjacency matrix for a given motif and motif type, optionally restrict it to its largest connected component, and then run Laplace embedding with specified Laplacian type and number of eigenvalues and eigenvectors.
MotifCluster.adjusted_rand_index — MethodCompute the adjusted Rand index between two clusterings.
MotifCluster.cluster_spectrum — MethodGet cluster assignments from a spectrum using k-means++.
MotifCluster.run_motif_clustering — MethodRun motif-based spectral clustering on the adjacency matrix of a (weighted directed) network, using a specified motif, motif type, weighting scheme, embedding dimension, number of clusters and Laplacian type. Optionally restrict to the largest connected component before clustering.
MotifCluster.demonstration_graph — MethodGenerate a small graph for demonstrations.
MotifCluster.random_sparse_matrix — MethodBuild a sparse matrix of size m, n with non-zero probability p. Edge weights can be unweighted, constant-weighted or Poisson-weighted.
MotifCluster.sample_bsbm — MethodSample the (weighted) adjacency matrix of a (weighted) bipartite stochastic block model (BSBM).
MotifCluster.sample_dsbm — MethodSample the (weighted) adjacency matrix of a (weighted) directed stochastic block model (DSBM) with specified parameters.