graphclust.graphs#
Graphs built from data: neighborhood graphs, spanning trees and graph distances.
Every function returns a symmetric scipy.sparse.csr_matrix whose
entry \((i,j)\) is the Euclidean length of the edge between samples
\(\mathbf{x}_i\) and \(\mathbf{x}_j\) (zero means “no edge”). This is
the format of scipy.sparse.csgraph, so shortest paths, connected
components and spanning trees can be computed directly; to_networkx()
converts the result for community detection or drawing.
The proximity graphs form the classical chain
which neighborhood_chain() verifies on a data set.
Neighborhood graphs, spanning trees, shared neighbors and geodesic distances.
Functions#
|
Induced Delaunay triangulation by competitive Hebbian learning (Martinetz 1993). |
|
Join the connected components of a graph by its shortest inter-component edges. |
Delaunay triangulation as a graph (practical up to about six dimensions). |
|
|
Undirected edge list |
|
\(\varepsilon\)-neighborhood graph: samples closer than |
Gabriel graph: \(\mathbf{x}_i,\mathbf{x}_j\) are linked when the ball with diameter \(\overline{\mathbf{x}_i\mathbf{x}_j}\) contains no other sample. |
|
|
All-pairs shortest-path (graph, geodesic) distances with Dijkstra's algorithm. |
|
Symmetric \(k\)-nearest-neighbor graph. |
|
Indices and distances of the |
|
Euclidean minimal spanning tree (symmetric) of the samples or of a given weighted graph. |
|
Mutual \(k\)-nearest-neighbor graph: an edge only if each sample is among the other's neighbors. |
Nearest neighbor graph (NNG): every sample is linked to its single nearest neighbor. |
|
Edge counts of NNG, MST, RNG, Gabriel graph and Delaunay triangulation, and whether each is contained in the next (for 2-D or 3-D data). |
|
Relative neighborhood graph (Toussaint): \(\mathbf{x}_i,\mathbf{x}_j\) are linked when no third sample is closer to both of them than they are to each other. |
|
|
Number of shared \(k\)-nearest neighbors \(m_{ij}=|A_i\cap A_j|\) for every pair. |
|
Convert a sparse adjacency matrix to a |