ó
 ,µ[c           @   sJ   d  Z  d d l Z d d l m Z m Z d g Z e d ƒ d „  ƒ Z d S(   s   Semiconnectedness.iÿÿÿÿN(   t   not_implemented_fort   pairwiset   is_semiconnectedt
   undirectedc            su   t  ˆ  ƒ d k r$ t j d ƒ ‚ n  t j ˆ  ƒ s7 t St j ˆ  ƒ ‰  t j ˆ  ƒ } t ‡  f d †  t | ƒ Dƒ ƒ S(   su  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 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
    i    s-   Connectivity is undefined for the null graph.c         3   s'   |  ] \ } } ˆ  j  | | ƒ Vq d  S(   N(   t   has_edge(   t   .0t   ut   v(   t   G(    sK   lib/python2.7/site-packages/networkx/algorithms/components/semiconnected.pys	   <genexpr>C   s    (	   t   lent   nxt   NetworkXPointlessConceptt   is_weakly_connectedt   Falset   condensationt   topological_sortt   allR   (   R   t   path(    (   R   sK   lib/python2.7/site-packages/networkx/algorithms/components/semiconnected.pyR      s    )(   t   __doc__t   networkxR
   t   networkx.utilsR    R   t   __all__R   (    (    (    sK   lib/python2.7/site-packages/networkx/algorithms/components/semiconnected.pyt   <module>
   s   	