ó
ú£Õ\c           @   sX   d  Z  d j d d d g ƒ Z d d d g Z d d	 l Z d
 „  Z d „  Z d „  Z d	 S(   s   
Degree centrality measures.

s   
s   Aric Hagberg (hagberg@lanl.gov)s   Pieter Swart (swart@lanl.gov)s#   Sasha Gutfraind (ag362@cornell.edu)t   degree_centralityt   in_degree_centralityt   out_degree_centralityiÿÿÿÿNc            s@   i  } d t  |  ƒ d ‰  t ‡  f d †  |  j ƒ  Dƒ ƒ } | S(   sê  Compute the degree centrality for nodes.

    The degree centrality for a node v is the fraction of nodes it
    is connected to.

    Parameters
    ----------
    G : graph
      A networkx graph 

    Returns
    -------
    nodes : dictionary
       Dictionary of nodes with degree centrality as the value.

    See Also
    --------
    betweenness_centrality, load_centrality, eigenvector_centrality

    Notes
    -----
    The degree centrality values are normalized by dividing by the maximum 
    possible degree in a simple graph n-1 where n is the number of nodes in G.

    For multigraphs or graphs with self loops the maximum degree might
    be higher than n-1 and values of degree centrality greater than 1
    are possible.
    g      ð?c         3   s%   |  ] \ } } | | ˆ  f Vq d  S(   N(    (   t   .0t   nt   d(   t   s(    sa   /Users/dxp/prism/prism-games/prism-examples/smgs/car/networkx/algorithms/centrality/degree_alg.pys	   <genexpr>4   s    (   t   lent   dictt   degree_iter(   t   Gt
   centrality(    (   R   sa   /Users/dxp/prism/prism-games/prism-examples/smgs/car/networkx/algorithms/centrality/degree_alg.pyR       s    "c            s^   |  j  ƒ  s t j d ƒ ‚ n  i  } d t |  ƒ d ‰  t ‡  f d †  |  j ƒ  Dƒ ƒ } | S(   sí  Compute the in-degree centrality for nodes.

    The in-degree centrality for a node v is the fraction of nodes its 
    incoming edges are connected to.

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

    Returns
    -------
    nodes : dictionary
        Dictionary of nodes with in-degree centrality as values.

    See Also
    --------
    degree_centrality, out_degree_centrality

    Notes
    -----
    The degree centrality values are normalized by dividing by the maximum 
    possible degree in a simple graph n-1 where n is the number of nodes in G.

    For multigraphs or graphs with self loops the maximum degree might
    be higher than n-1 and values of degree centrality greater than 1
    are possible.
    s9   in_degree_centrality() not defined for undirected graphs.g      ð?c         3   s%   |  ] \ } } | | ˆ  f Vq d  S(   N(    (   R   R   R   (   R   (    sa   /Users/dxp/prism/prism-games/prism-examples/smgs/car/networkx/algorithms/centrality/degree_alg.pys	   <genexpr>Y   s    (   t   is_directedt   nxt   NetworkXErrorR   R   t   in_degree_iter(   R
   R   (    (   R   sa   /Users/dxp/prism/prism-games/prism-examples/smgs/car/networkx/algorithms/centrality/degree_alg.pyR   7   s    "c            s^   |  j  ƒ  s t j d ƒ ‚ n  i  } d t |  ƒ d ‰  t ‡  f d †  |  j ƒ  Dƒ ƒ } | S(   sï  Compute the out-degree centrality for nodes.

    The out-degree centrality for a node v is the fraction of nodes its 
    outgoing edges are connected to.

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

    Returns
    -------
    nodes : dictionary
        Dictionary of nodes with out-degree centrality as values.

    See Also
    --------
    degree_centrality, in_degree_centrality

    Notes
    -----
    The degree centrality values are normalized by dividing by the maximum 
    possible degree in a simple graph n-1 where n is the number of nodes in G.

    For multigraphs or graphs with self loops the maximum degree might
    be higher than n-1 and values of degree centrality greater than 1
    are possible.
    s:   out_degree_centrality() not defined for undirected graphs.g      ð?c         3   s%   |  ] \ } } | | ˆ  f Vq d  S(   N(    (   R   R   R   (   R   (    sa   /Users/dxp/prism/prism-games/prism-examples/smgs/car/networkx/algorithms/centrality/degree_alg.pys	   <genexpr>   s    (   R   R   R   R   R   t   out_degree_iter(   R
   R   (    (   R   sa   /Users/dxp/prism/prism-games/prism-examples/smgs/car/networkx/algorithms/centrality/degree_alg.pyR   ]   s    "(	   t   __doc__t   joint
   __author__t   __all__t   networkxR   R    R   R   (    (    (    sa   /Users/dxp/prism/prism-games/prism-examples/smgs/car/networkx/algorithms/centrality/degree_alg.pyt   <module>   s   			"	&