is_semiconnected

is_semiconnected#

graph_tool.structure.is_semiconnected(g)[git][source]#

Check whether a directed graph is semiconnected.

Parameters:
gGraph

Directed graph.

Returns:
semiconnectedbool

True if, for every pair of vertices \(u, v\), there is a path from \(u\) to \(v\) or from \(v\) to \(u\).

See also

label_components

Strongly connected components

graph_tool.generation.condensation_graph

Graph of the strong components

Notes

A directed graph is semiconnected if and only if its condensation (the acyclic graph of its strongly connected components) has a Hamiltonian path, i.e. if consecutive components in topological order are joined by an edge. The time is \(O(V + E)\).

Examples

>>> print(gt.is_semiconnected(gt.Graph([(0, 1), (1, 2)])),
...       gt.is_semiconnected(gt.Graph([(0, 1), (0, 2)])))
True False