ó
|£*^c           @   sS   d  Z  d d l Z d d l Td Z d d g Z d e d d	 „ Z e Z d
 „  Z	 d S(   s,   Current-flow closeness centrality measures.
iÿÿÿÿN(   t   *s%   Aric Hagberg <aric.hagberg@gmail.com>t!   current_flow_closeness_centralityt   information_centralityt   weightt   luc      
      sÓ  d d l  m } d d l } d d l } |  j ƒ  rF t j d ƒ ‚ n  t j |  ƒ sg t j d ƒ ‚ n  i t d 6t	 d 6t
 d 6} |  j ƒ  } t | |  ƒ ƒ ‰  t j |  t t ˆ  t | ƒ ƒ ƒ ƒ }	 t j |	 d	 ƒ }
 |	 j ƒ  } t |	 d
 t | ƒ d | d | d d ƒ} | | | d d d | ƒ} xb |	 D]Z } | j | ƒ } xB |	 D]: } |
 | c | | d | | 7<|
 | c | | 7<qNWq2Wx  |	 D] } d |
 | |
 | <q—Wt ‡  f d †  |
 j ƒ  Dƒ ƒ S(   sÖ  Compute current-flow closeness centrality for nodes.

    Current-flow closeness centrality is variant of closeness
    centrality based on effective resistance between nodes in
    a network. This metric is also known as information centrality.

    Parameters
    ----------
    G : graph
      A NetworkX graph

    dtype: data type (float)
      Default data type for internal matrices.
      Set to np.float32 for lower memory consumption.

    solver: string (default='lu')
       Type of linear solver to use for computing the flow matrix.
       Options are "full" (uses most memory), "lu" (recommended), and
       "cg" (uses least memory).

    Returns
    -------
    nodes : dictionary
       Dictionary of nodes with current flow closeness centrality as the value.

    See Also
    --------
    closeness_centrality

    Notes
    -----
    The algorithm is from Brandes [1]_.

    See also [2]_ for the original definition of information centrality.

    References
    ----------
    .. [1] Ulrik Brandes and Daniel Fleischer,
       Centrality Measures Based on Current Flow.
       Proc. 22nd Symp. Theoretical Aspects of Computer Science (STACS '05).
       LNCS 3404, pp. 533-544. Springer-Verlag, 2005.
       http://www.inf.uni-konstanz.de/algo/publications/bf-cmbcf-05.pdf

    .. [2] Karen Stephenson and Marvin Zelen:
       Rethinking centrality: Methods and examples.
       Social Networks 11(1):1-37, 1989.
       http://dx.doi.org/10.1016/0378-8733(89)90016-6
    iÿÿÿÿ(   t   reverse_cuthill_mckee_orderingNs=   current_flow_closeness_centrality() not defined for digraphs.s   Graph not connected.t   fullR   t   cgg        t   nodelistR   t   dtypet   formatt   csct   widthi   i   g      ð?c         3   s+   |  ]! \ } } ˆ  | t  | ƒ f Vq d  S(   N(   t   float(   t   .0t   kt   v(   t   ordering(    s‰   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/centrality/current_flow_closeness.pys	   <genexpr>^   s    (   t   networkx.utilsR   t   numpyt   scipyt   is_directedt   nxt   NetworkXErrort   is_connectedt   FullInverseLaplaciant   SuperLUInverseLaplaciant   CGInverseLaplaciant   number_of_nodest   listt   relabel_nodest   dictt   zipt   ranget   fromkeyst   laplacian_sparse_matrixt   get_rowt   items(   t   GR   R	   t   solverR   t   npR   t
   solvernamet   nt   Ht   betweennesst   Lt   C2R   t   colt   w(    (   R   s‰   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/centrality/current_flow_closeness.pyR      s6    2

' c         C   s:   d d l  m } y d d  l } Wn | d ƒ ‚ n Xd  S(   Niÿÿÿÿ(   t   SkipTests   NumPy not available(   t   noseR1   R   (   t   moduleR1   R   (    (    s‰   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/centrality/current_flow_closeness.pyt   setup_moduled   s
    (
   t   __doc__t   networkxR   t*   networkx.algorithms.centrality.flow_matrixt
   __author__t   __all__R   R   R   R4   (    (    (    s‰   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/centrality/current_flow_closeness.pyt   <module>   s   
Q