Check connectivity of the given matrix.
- C (scipy.sparse matrix) – Count matrix specifying edge weights.
- directed (bool, optional) – Whether to compute connected components for a directed or undirected graph. Default is True.
is_connected – True if C is connected, False otherwise.
A count matrix is connected if the graph having the count matrix as adjacency matrix has a single connected component. Connectivity of a graph can be efficiently checked using Tarjan’s algorithm.
 Tarjan, R E. 1972. Depth-first search and linear graph algorithms. SIAM Journal on Computing 1 (2): 146-160.
>>> import numpy as np >>> from msmtools.estimation import is_connected
>>> C = np.array([[10, 1, 0], [2, 0, 3], [0, 0, 4]]) >>> is_connected(C) False
>>> is_connected(C, directed=False) True