Expand description
Minimum and maximum spanning forests over CSR adjacencies.
Kruskal with union-find. The adjacency is read as undirected: a stored entry connects its endpoints whichever direction it sits in, so a directed CSR needs no transpose. Where a pair is stored in both directions with different weights, the weight that favours the objective wins (smaller for the minimum forest, larger for the maximum one).
Disconnected input yields a forest rather than an error, matching
scipy.sparse.csgraph.minimum_spanning_tree. Two deliberate divergences
from that routine: explicitly stored zero weights are kept as real edges
(scipy treats a zero as an absent edge), and ties resolve by (weight, lo, hi) so the output does not depend on traversal order.
Functionsยง
- maximum_
spanning_ forest - Maximum spanning forest of a CSR adjacency.
- minimum_
spanning_ forest - Minimum spanning forest of a CSR adjacency.