U
    ª9%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_semiconnectedZ
undirectedc                    sZ   t ˆ ƒdkrt d¡‚t ˆ ¡s$dS t ˆ ¡‰ |dk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)Zhas_edge)Ú.0ÚuÚv©ÚG© úk/var/www/html/Darija-Ai-API/env/lib/python3.8/site-packages/networkx/algorithms/components/semiconnected.pyÚ	<genexpr>@   s     z#is_semiconnected.<locals>.<genexpr>)ÚlenÚnxZNetworkXPointlessConceptZis_weakly_connectedZcondensationZtopological_sortÚallr   )r	   Z
topo_orderr
   r   r   r      s    ,ÿ


)N)Ú__doc__Znetworkxr   Znetworkx.utilsr   r   Ú__all__r   r
   r
   r
   r   Ú<module>   s
   