Hi
The min_spanning_tree function works only for connected graph. So in ordrer to 
find a minimum spanning forest of a undirected weighted graph (say G), I need 
to retrieve the connected components of G. I can do it with the 
label_components function. The problem I have now is I don't know how to build 
the subgraph induced by each connected component. Here is the piece of code I 
am working from :



# ----------------------------
import graph_tool as gt
from graph_tool.topology import min_spanning_tree, label_components
import numpy as np

wedges=[(1, 2, 3.), (0, 2, 6.), (3, 4, 1.)] 
g= gt.Graph(directed=False)
weight = g.new_edge_property("double")
g.add_edge_list(np.array(wedges), eprops=[weight])
u, v=label_components(g)
print(u.a)
# ----------------------------

outputting


[0 0 0 1 1]


Can somebody explain how to retrieve the subgraph of g induced by the connected 
component labeled 0? 


Thanks in advance



_______________________________________________
graph-tool mailing list
[email protected]
https://lists.skewed.de/mailman/listinfo/graph-tool

Reply via email to