Warning

This documents an unmaintained version of NetworkX. Please upgrade to a maintained version and see the current NetworkX documentation.

is_semiconnected

is_semiconnected(G)[source]

Return 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.

Returns:

semiconnected : bool

True if the graph is semiconnected, False otherwise.

Raises:

NetworkXNotImplemented :

If the input graph is not directed.

NetworkXPointlessConcept :

If the graph is empty.

See also

is_strongly_connected, is_weakly_connected

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