nocad.components.strongly_connected_components#

nocad.components.strongly_connected_components(adj)[source]#

Label of the strongly connected component of every node.

Labels are 0..p-1 in a topological order of the condensation: every edge between two components goes from a smaller to a larger label.

Parameters:
adjarray_like or sparse, shape (N, N)
Returns:
labelsndarray of shape (N,)

Examples

>>> strongly_connected_components([[0, 1, 0], [1, 0, 1], [0, 0, 0]])
array([0, 0, 1])