#NEWLINE# @ not_implemented_for ( 'undirected' ) #NEWLINE# def is_semiconnected( G ) : #NEWLINE# #INDENT# 'Return True if the graph is semiconnected, False otherwise.\n\n    A graph is semiconnected if, and only if, for any pair of nodes, either one\n    is reachable from the other, or they are mutually reachable.\n\n    Parameters\n    ----------\n    G : NetworkX graph\n        A directed graph.\n\n    Returns\n    -------\n    semiconnected : bool\n        True if the graph is semiconnected, False otherwise.\n\n    Raises\n    ------\n    NetworkXNotImplemented :\n        If the input graph is undirected.\n\n    NetworkXPointlessConcept :\n        If the graph is empty.\n\n    Examples\n    --------\n    >>> G=nx.path_graph(4,create_using=nx.DiGraph())\n    >>> print(nx.is_semiconnected(G))\n    True\n    >>> G=nx.DiGraph([(1, 2), (3, 2)])\n    >>> print(nx.is_semiconnected(G))\n    False\n\n    See Also\n    --------\n    is_strongly_connected\n    is_weakly_connected\n    is_connected\n    is_biconnected\n    ' #NEWLINE# if ( len ( G ) == 0 ) : #NEWLINE# #INDENT# raise nx . NetworkXPointlessConcept ( 'Connectivity is undefined for the null graph.' ) #NEWLINE# #UNINDENT# if ( not nx . is_weakly_connected ( G ) ) : #NEWLINE# #INDENT# return False #NEWLINE# #UNINDENT# G = nx . condensation ( G ) #NEWLINE# path = nx . topological_sort ( G ) #NEWLINE# return all ( ( G . has_edge ( u , v ) for ( u , v ) in pairwise ( path ) ) )