make_connected#
- graph_tool.structure.make_connected(g)[git][source]#
Add edges to a graph to make it connected.
- Parameters:
- g
Graph Graph to be modified. Edge directions are ignored.
- g
- Returns:
- edges
numpy.ndarray Array of shape
(k, 2)with the endpoints of the added edges.
- edges
See also
label_componentsConnected components
graph_tool.flow.k_edge_augmentationEdges for k-edge-connectivity
Notes
The components are ordered by their vertices of lowest index, ignoring the edge directions, and an edge is added from the vertex of highest index of every component to the vertex of lowest index of the next one, so that \(C - 1\) edges connect \(C\) components, in time \(O(V + E)\).
Examples
>>> g = gt.Graph([(0, 1), (2, 3), (4, 5)], directed=False) >>> print(gt.make_connected(g)) [[1 2] [3 4]] >>> print(gt.label_components(g)[1]) [6]