diplomat.utils.graph_ops.connected_components

diplomat.utils.graph_ops.connected_components(graph: ndarray) Tuple[int, ndarray][source]

Compute the connected components of a graph.

Parameters:

graph – An adjacency matrix representing a graph, stored as a 2D numpy array.

Returns:

A tuple of 2 values, the first value being the number of components (integer), and the second value being an array of identifiers, specifying which component each node belongs to.