msmtools.estimation.is_connected¶

msmtools.estimation.
is_connected
(C, directed=True)¶ Check connectivity of the given matrix.
Parameters:  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.
Returns: is_connected – True if C is connected, False otherwise.
Return type: bool
See also
Notes
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.
References
[1] Tarjan, R E. 1972. Depthfirst search and linear graph algorithms. SIAM Journal on Computing 1 (2): 146160. Examples
>>> 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