ó
|£*^c           @   sı   d  Z  d d l Z d d l m Z d j d d g  Z d d d	 d
 d g Z e d  d    Z e d  e	 d   Z
 d   Z e d  d    Z e d  d    Z d   Z d S(   s   
Connected components.
i˙˙˙˙N(   t   not_implemented_fors   
s
   Eben Kenahs8   Aric Hagberg <aric.hagberg@gmail.com>Christopher Ellisont   number_connected_componentst   connected_componentst   connected_component_subgraphst   is_connectedt   node_connected_componentt   directedc         c   sT   t    } xD |  D]< } | | k r t  t |  |   } | V| j |  q q Wd S(   s  Generate connected components.

    Parameters
    ----------
    G : NetworkX graph
       An undirected graph

    Returns
    -------
    comp : generator of sets
       A generator of sets of nodes, one for each component of G.

    Examples
    --------
    Generate a sorted list of connected components, largest first.

    >>> G = nx.path_graph(4)
    >>> G.add_path([10, 11, 12])
    >>> [len(c) for c in sorted(nx.connected_components(G), key=len, reverse=True)]
    [4, 3]

    If you only want the largest connected component, it's more
    efficient to use max instead of sort.

    >>> largest_cc = max(nx.connected_components(G), key=len)

    See Also
    --------
    strongly_connected_components

    Notes
    -----
    For undirected graphs only.

    N(   t   sett
   _plain_bfst   update(   t   Gt   seent   vt   c(    (    s|   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/components/connected.pyR      s    %	c         c   sF   x? t  |   D]1 } | r0 |  j |  j   Vq |  j |  Vq Wd S(   s,  Generate connected components as subgraphs.

    Parameters
    ----------
    G : NetworkX graph
       An undirected graph.

    copy: bool (default=True)
      If True make a copy of the graph attributes

    Returns
    -------
    comp : generator
      A generator of graphs, one for each connected component of G.

    Examples
    --------
    >>> G = nx.path_graph(4)
    >>> G.add_edge(5,6)
    >>> graphs = list(nx.connected_component_subgraphs(G))

    If you only want the largest connected component, it's more
    efficient to use max than sort.

    >>> Gc = max(nx.connected_component_subgraphs(G), key=len)

    See Also
    --------
    connected_components

    Notes
    -----
    For undirected graphs only.
    Graph, node, and edge attributes are copied to the subgraphs by default.

    N(   R   t   subgrapht   copy(   R
   R   R   (    (    s|   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/components/connected.pyR   G   s    &c         C   s   t  t t |     S(   s:  Return the number of connected components.

    Parameters
    ----------
    G : NetworkX graph
       An undirected graph.

    Returns
    -------
    n : integer
       Number of connected components

    See Also
    --------
    connected_components

    Notes
    -----
    For undirected graphs only.

    (   t   lent   listR   (   R
   (    (    s|   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/components/connected.pyR   t   s    c         C   sX   t  |   d k r' t j d d   n  t  t t |  t |  j       t  |   k S(   sÀ  Return True if the graph is connected, false otherwise.

    Parameters
    ----------
    G : NetworkX Graph
       An undirected graph.

    Returns
    -------
    connected : bool
      True if the graph is connected, false otherwise.

    Examples
    --------
    >>> G = nx.path_graph(4)
    >>> print(nx.is_connected(G))
    True

    See Also
    --------
    connected_components

    Notes
    -----
    For undirected graphs only.

    i    s   Connectivity is undefined s   for the null graph.(   R   t   nxt   NetworkXPointlessConceptR   R   t   nextt
   nodes_iter(   R
   (    (    s|   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/components/connected.pyR      s    	c         C   s   t  t |  |   S(   s  Return the nodes in the component of graph containing node n.

    Parameters
    ----------
    G : NetworkX Graph
       An undirected graph.

    n : node label
       A node in G

    Returns
    -------
    comp : set
       A set of nodes in the component of G containing node n.

    See Also
    --------
    connected_components

    Notes
    -----
    For undirected graphs only.

    (   R   R   (   R
   t   n(    (    s|   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/components/connected.pyR   °   s    c         c   su   t    } | h } x\ | rp | } t    } x@ | D]8 } | | k r1 | V| j |  | j |  |  q1 q1 Wq Wd S(   s   A fast BFS node generatorN(   R   t   addR	   (   R
   t   sourceR   t	   nextlevelt	   thislevelR   (    (    s|   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/components/connected.pyR   Í   s    				(   t   __doc__t   networkxR   t   networkx.utils.decoratorsR    t   joint   __authors__t   __all__R   t   TrueR   R   R   R   R   (    (    (    s|   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/components/connected.pyt   <module>   s    		-	,	#