Skip to content

Commit 10f82b4

Browse files
authored
DOC: sparse.csgraph: Clarify minimum_spanning_tree behaviour in non-connected case. (scipy#17287)
AFAICT, Kruskal's algorithm (as implemented in _min_spanning_tree.pyx) works as is for the non-connected case as well: the loop `while i < n_data and n_edges_in_mst < n_verts - 1` simply keeps going while never finding an edge that connects separate components, and the separate components are effectively processed independently. The behavior is also consistent with networkx's minimum_spanning_edges.
1 parent bc73228 commit 10f82b4

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

scipy/sparse/csgraph/_min_spanning_tree.pyx

+3
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ def minimum_spanning_tree(csgraph, overwrite=False):
5050
Small elements < 1E-8 of the dense matrix are rounded to zero.
5151
All users should input sparse matrices if possible to avoid it.
5252
53+
If the graph is not connected, this routine returns the minimum spanning
54+
forest, i.e. the union of the minimum spanning trees on each connected
55+
component.
5356
5457
Examples
5558
--------

0 commit comments

Comments
 (0)