make_connected

Contents

make_connected#

graph_tool.structure.make_connected(g)[git][source]#

Add edges to a graph to make it connected.

Parameters:
gGraph

Graph to be modified. Edge directions are ignored.

Returns:
edgesnumpy.ndarray

Array of shape (k, 2) with the endpoints of the added edges.

See also

label_components

Connected components

graph_tool.flow.k_edge_augmentation

Edges 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]