ó
|£*^c           @   s   d  Z  d j d d g ƒ Z d d d d d g Z d	 d
 l Z d
 d
 d „ Z d
 d „ Z d
 d „ Z d
 d „ Z	 d
 d „ Z
 d
 S(   s<   
Graph diameter, radius, eccentricity and other properties.
s   
s   Aric Hagberg (hagberg@lanl.gov)s   Dan Schult(dschult@colgate.edu)t   eccentricityt   diametert   radiust	   peripheryt   centeriÿÿÿÿNc   	      C   sì   |  j  ƒ  } i  } x» |  j | ƒ D]ª } | d k rU t j |  | ƒ } t | ƒ } n= y | | } t | ƒ } Wn  t k
 r‘ t j d ƒ ‚ n X| | k r¶ d } t j | ƒ ‚ n  t | j	 ƒ  ƒ | | <q" W| |  k rä | | S| Sd S(   së  Return the eccentricity of nodes in G.

    The eccentricity of a node v is the maximum distance from v to
    all other nodes in G.

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

    v : node, optional
       Return value of specified node       

    sp : dict of dicts, optional       
       All pairs shortest path lengths as a dictionary of dictionaries

    Returns
    -------
    ecc : dictionary
       A dictionary of eccentricity values keyed by node.
    s   Format of "sp" is invalid.s)   Graph not connected: infinite path lengthN(
   t   ordert   nbunch_itert   Nonet   networkxt"   single_source_shortest_path_lengtht   lent	   TypeErrort   NetworkXErrort   maxt   values(	   t   Gt   vt   spR   t   et   nt   lengtht   Lt   msg(    (    sy   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/distance_measures.pyR       s$    
c         C   s+   | d k r t |  ƒ } n  t | j ƒ  ƒ S(   sg  Return the diameter of the graph G.

    The diameter is the maximum eccentricity.

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

    e : eccentricity dictionary, optional
      A precomputed dictionary of eccentricities.

    Returns
    -------
    d : integer
       Diameter of graph

    See Also
    --------
    eccentricity
    N(   R   R    R   R   (   R   R   (    (    sy   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/distance_measures.pyR   I   s    c         C   sZ   | d k r t |  ƒ } n  t | j ƒ  ƒ } g  | D] } | | | k r4 | ^ q4 } | S(   se  Return the periphery of the graph G. 

    The periphery is the set of nodes with eccentricity equal to the diameter. 

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

    e : eccentricity dictionary, optional
      A precomputed dictionary of eccentricities.

    Returns
    -------
    p : list
       List of nodes in periphery
    N(   R   R    R   R   (   R   R   R   R   t   p(    (    sy   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/distance_measures.pyR   c   s
    )c         C   s+   | d k r t |  ƒ } n  t | j ƒ  ƒ S(   s5  Return the radius of the graph G.

    The radius is the minimum eccentricity.

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

    e : eccentricity dictionary, optional
      A precomputed dictionary of eccentricities.

    Returns
    -------
    r : integer
       Radius of graph
    N(   R   R    t   minR   (   R   R   (    (    sy   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/distance_measures.pyR   |   s    c         C   sZ   | d k r t |  ƒ } n  t | j ƒ  ƒ } g  | D] } | | | k r4 | ^ q4 } | S(   sV  Return the center of the graph G. 

    The center is the set of nodes with eccentricity equal to radius. 

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

    e : eccentricity dictionary, optional
      A precomputed dictionary of eccentricities.

    Returns
    -------
    c : list
       List of nodes in center
    N(   R   R    R   R   (   R   R   R   R   R   (    (    sy   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/distance_measures.pyR   ’   s
    )(   t   __doc__t   joint
   __author__t   __all__R   R   R    R   R   R   R   (    (    (    sy   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/algorithms/distance_measures.pyt   <module>   s   	7