o
    ˷e4                     @   s8   d Z ddlZddlmZmZ dgZeddddZdS )zSemiconnectedness.    N)not_implemented_forpairwiseis_semiconnected
undirectedc                    sZ   t  dkrtdt sdS t  |du r t }t fddt|D S )a  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 : bool
        True if the graph is semiconnected, False otherwise.

    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

    See Also
    --------
    is_strongly_connected
    is_weakly_connected
    is_connected
    is_biconnected
    r   z-Connectivity is undefined for the null graph.FNc                 3   s     | ]\}}  ||V  qd S N)has_edge).0uvG c/var/www/ideatree/venv/lib/python3.10/site-packages/networkx/algorithms/components/semiconnected.py	<genexpr>@   s    z#is_semiconnected.<locals>.<genexpr>)lennxNetworkXPointlessConceptis_weakly_connectedcondensationtopological_sortallr   )r   
topo_orderr   r   r   r      s   ,


r   )__doc__networkxr   networkx.utilsr   r   __all__r   r   r   r   r   <module>   s    