ó
|Ģ*^c           @   sĄ   d  Z  d d l Z d d l m Z d j d g  Z d d d d	 g Z e d
  d    Z e d
  d    Z	 e d
  d    Z
 e d
  e d   Z d S(   s   
Attracting components.
iĸĸĸĸN(   t   not_implemented_fors   
s   Christopher Ellisont   number_attracting_componentst   attracting_componentst   is_attracting_componentt   attracting_component_subgraphst
   undirectedc         c   s]   t  t j |    } t j |  |  } x/ | D]' } | j |  d k r. | | Vq. q. Wd S(   s6  Generates a list of attracting components in `G`.

    An attracting component in a directed graph `G` is a strongly connected
    component with the property that a random walker on the graph will never
    leave the component, once it enters the component.

    The nodes in attracting components can also be thought of as recurrent
    nodes.  If a random walker enters the attractor containing the node, then
    the node will be visited infinitely often.

    Parameters
    ----------
    G : DiGraph, MultiDiGraph
        The graph to be analyzed.

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

    See Also
    --------
    number_attracting_components
    is_attracting_component 
    attracting_component_subgraphs

    i    N(   t   listt   nxt   strongly_connected_componentst   condensationt
   out_degree(   t   Gt   scct   cGt   n(    (    s}   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/components/attracting.pyR      s
    c         C   s   t  t t |     } | S(   sc  Returns the number of attracting components in `G`.

    Parameters
    ----------
    G : DiGraph, MultiDiGraph
        The graph to be analyzed.

    Returns
    -------
    n : int
        The number of attracting components in G.

    See Also
    --------
    attracting_components
    is_attracting_component
    attracting_component_subgraphs

    (   t   lenR   R   (   R   R   (    (    s}   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/components/attracting.pyR   7   s    c         C   sA   t  t |    } t | d  t |   k r7 t } n t } | S(   s  Returns True if `G` consists of a single attracting component.

    Parameters
    ----------
    G : DiGraph, MultiDiGraph
        The graph to be analyzed.

    Returns
    -------
    attracting : bool
        True if `G` has a single attracting component. Otherwise, False.

    See Also
    --------
    attracting_components
    number_attracting_components
    attracting_component_subgraphs

    i    (   R   R   R   t   Truet   False(   R   t   act
   attracting(    (    s}   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/components/attracting.pyR   P   s
    	c         c   sF   x? t  |   D]1 } | r0 |  j |  j   Vq |  j |  Vq Wd S(   s   Generates a list of attracting component subgraphs from `G`.

    Parameters
    ----------
    G : DiGraph, MultiDiGraph
        The graph to be analyzed.

    Returns
    -------
    subgraphs : list
        A list of node-induced subgraphs of the attracting components of `G`.

    copy : bool
        If copy is True, graph, node, and edge attributes are copied to the 
        subgraphs.

    See Also
    --------
    attracting_components
    number_attracting_components
    is_attracting_component

    N(   R   t   subgrapht   copy(   R   R   R   (    (    s}   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/components/attracting.pyR   m   s    (   t   __doc__t   networkxR   t   networkx.utils.decoratorsR    t   joint   __authors__t   __all__R   R   R   R   R   (    (    (    s}   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/components/attracting.pyt   <module>   s   	#	