is_aperiodic#
- graph_tool.structure.is_aperiodic(g)[git][source]#
Check whether a strongly connected directed graph is aperiodic.
- Parameters:
- g
Graph Strongly connected directed graph.
- g
- Returns:
- aperiodic
bool Trueif the greatest common divisor of the cycle lengths is one.
- aperiodic
See also
label_componentsStrongly connected components
is_DAGTest for directed acyclic graphs
Notes
A random walk on a strongly connected graph converges to its stationary distribution if and only if the graph is aperiodic. With the breadth-first levels \(l\) from any vertex, the greatest common divisor of the cycle lengths equals that of \(l(u) + 1 - l(v)\) over the edges \((u, v)\) [jarvis-graph-1996], which is computed in time \(O(V + E)\). A
ValueErroris raised if the graph is not strongly connected.References
[jarvis-graph-1996]J. P. Jarvis and D. R. Shier, “Graph-theoretic analysis of finite Markov chains”, in Applied Mathematical Modeling: A Multidisciplinary Approach, CRC Press (1996).
Examples
>>> print(gt.is_aperiodic(gt.circular_graph(4, directed=True))) False >>> g = gt.circular_graph(4, directed=True) >>> g.add_edge(0, 2) <...> >>> print(gt.is_aperiodic(g)) True