Skip to main content

Module graph_components

Module graph_components 

Source
Expand description

Connected components over CSR adjacency matrices.

Components are weak: a stored edge connects its endpoints regardless of direction, matching scipy.sparse.csgraph.connected_components with directed=False. Union-find is what makes that cheap on a directed CSR — it unions each stored edge, so no transpose is needed to see the in-edges.

Labels are assigned by scanning nodes in ascending order and numbering roots on first encounter, which reproduces scipy’s labelling.

Functions§

connected_components
Weakly connected components of a CSR adjacency.
induced_components
Weakly connected components of the subgraph induced by members.