deeptime.markov.tools.estimation.is_connected

deeptime.markov.tools.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

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 [1].

References

Examples

>>> import numpy as np
>>> from deeptime.markov.tools.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