networkx.algorithms.components.is_semiconnected¶
-
is_semiconnected
(G, topo_order=None)[source]¶ Returns True if the graph is semiconnected, False otherwise.
A graph is semiconnected if, and only if, for any pair of nodes, either one is reachable from the other, or they are mutually reachable.
- Parameters
G (NetworkX graph) – A directed graph.
topo_order (list or tuple, optional) – A topological order for G (if None, the function will compute one)
- Returns
semiconnected – True if the graph is semiconnected, False otherwise.
- Return type
- Raises
NetworkXNotImplemented : – If the input graph is undirected.
NetworkXPointlessConcept : – If the graph is empty.
Examples
>>> G=nx.path_graph(4,create_using=nx.DiGraph()) >>> print(nx.is_semiconnected(G)) True >>> G=nx.DiGraph([(1, 2), (3, 2)]) >>> print(nx.is_semiconnected(G)) False