ó
 ,µ[c           @   s¶  d  Z  d d l m Z d d l Z d d l m Z d d d d d	 d
 d d d g	 Z d „  Z e d ƒ d d d d „ ƒ Z
 d d d d „ Z d d d d d „ Z d d d d( d „ Z e d ƒ d d d d d d d d d d d „
 ƒ Z e Z e d ƒ d d d d d d d d „ ƒ Z e d ƒ d d d d d d d d „ ƒ Z d d d d d d d  „ Z d! „  Z d" „  Z d d d d d# „ Z d d$ „ Z d d% „ Z d d& „ Z d' „  Z d S()   s‰  
******
Layout
******

Node positioning algorithms for graph drawing.

For `random_layout()` the possible resulting shape
is a square of side [0, scale] (default: [0, 1])
Changing `center` shifts the layout by that amount.

For the other layout routines, the extent is
[center - scale, center + scale] (default: [-1, 1]).

Warning: Most layout routines have only been tested in 2-dimensions.

iÿÿÿÿ(   t   divisionN(   t   random_statet   bipartite_layoutt   circular_layoutt   kamada_kawai_layoutt   random_layoutt   rescale_layoutt   shell_layoutt   spring_layoutt   spectral_layoutt   fruchterman_reingold_layoutc         C   sž   d d  l  } t |  t j ƒ s@ t j ƒ  } | j |  ƒ | }  n  | d  k r^ | j | ƒ } n | j | ƒ } t | ƒ | k r” d } t	 | ƒ ‚ n  |  | f S(   Niÿÿÿÿs;   length of center coordinates must match dimension of layout(
   t   numpyt
   isinstancet   nxt   Grapht   add_nodes_fromt   Nonet   zerost   asarrayt   lent
   ValueError(   t   Gt   centert   dimt   npt   empty_grapht   msg(    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyt   _process_params+   s    	i   i   c         C   sk   d d l  } t |  | | ƒ \ }  } | j t |  ƒ | ƒ | } | j | j ƒ } t t |  | ƒ ƒ } | S(   sN  Position nodes uniformly at random in the unit square.

    For every node, a position is generated by choosing each of dim
    coordinates uniformly at random on the interval [0.0, 1.0).

    NumPy (http://scipy.org) is required for this function.

    Parameters
    ----------
    G : NetworkX graph or list of nodes
        A position will be assigned to every node in G.

    center : array-like or None
        Coordinate pair around which to center the layout.

    dim : int
        Dimension of layout.

    seed : int, RandomState instance or None  optional (default=None)
        Set the random state for deterministic node layouts.
        If int, `seed` is the seed used by the random number generator,
        if numpy.random.RandomState instance, `seed` is the random
        number generator,
        if None, the random number generator is the RandomState instance used
        by numpy.random.

    Returns
    -------
    pos : dict
        A dictionary of positions keyed by node

    Examples
    --------
    >>> G = nx.lollipop_graph(4, 3)
    >>> pos = nx.random_layout(G)

    iÿÿÿÿN(   R   R   t   randR   t   astypet   float32t   dictt   zip(   R   R   R   t   seedR   t   pos(    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyR   @   s    'i   c         C   sI  d d l  } | d k  r' t d ƒ ‚ n  t |  | | ƒ \ }  } t d | d ƒ } t |  ƒ d k rm i  } nØ t |  ƒ d k r› i | t j j |  ƒ 6} nª | j d d t |  ƒ d ƒ d  d | j	 } | j
 | j ƒ } | j | j | ƒ | j | ƒ | j t |  ƒ | f ƒ g ƒ } t | d | ƒ| } t t |  | ƒ ƒ } | S(   sc  Position nodes on a circle.

    Parameters
    ----------
    G : NetworkX graph or list of nodes
        A position will be assigned to every node in G.

    scale : number (default: 1)
        Scale factor for positions.

    center : array-like or None
        Coordinate pair around which to center the layout.

    dim : int
        Dimension of layout.
        If dim>2, the remaining dimensions are set to zero
        in the returned positions.
        If dim<2, a ValueError is raised.

    Returns
    -------
    pos : dict
        A dictionary of positions keyed by node

    Raises
    -------
    ValueError
        If dim < 2

    Examples
    --------
    >>> G = nx.path_graph(4)
    >>> pos = nx.circular_layout(G)

    Notes
    -----
    This algorithm currently only works in two dimensions and does not
    try to minimize edge crossings.

    iÿÿÿÿNi   s   cannot handle dimensions < 2i    i   t   scale(   R   R   R   t   maxR   R   t   utilst   arbitrary_elementt   linspacet   piR   R   t   column_stackt   cost   sinR   R   R   R    (   R   R#   R   R   R   t   paddimsR"   t   theta(    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyR   q   s     *	.!c         C   s‡  d d l  } | d k r' t d ƒ ‚ n  t |  | | ƒ \ }  } t |  ƒ d k rU i  St |  ƒ d k r~ i | t j j |  ƒ 6S| d k rœ t |  ƒ g } n  t | d ƒ d k r» d } n d } i  } x¹ | D]± } | j	 d d t | ƒ d ƒ d  d | j
 }	 |	 j | j ƒ }	 | j | j |	 ƒ | j |	 ƒ g ƒ }
 t |
 d	 | | t | ƒ ƒ| }
 | j t | |
 ƒ ƒ | d 7} qÎ W| S(
   s¬  Position nodes in concentric circles.

    Parameters
    ----------
    G : NetworkX graph or list of nodes
        A position will be assigned to every node in G.

    nlist : list of lists
       List of node lists for each shell.

    scale : number (default: 1)
        Scale factor for positions.

    center : array-like or None
        Coordinate pair around which to center the layout.

    dim : int
        Dimension of layout, currently only dim=2 is supported.
        Other dimension values result in a ValueError.

    Returns
    -------
    pos : dict
        A dictionary of positions keyed by node

    Raises
    -------
    ValueError
        If dim != 2

    Examples
    --------
    >>> G = nx.path_graph(4)
    >>> shells = [[0], [1, 2, 3]]
    >>> pos = nx.shell_layout(G, shells)

    Notes
    -----
    This algorithm currently only works in two dimensions and does not
    try to minimize edge crossings.

    iÿÿÿÿNi   s   can only handle 2 dimensionsi    i   g        g      ð?R#   (   R   R   R   R   R   R%   R&   R   t   listR'   R(   R   R   R)   R*   R+   R   t   updateR    (   R   t   nlistR#   R   R   R   t   radiust   npost   nodesR-   R"   (    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyR   ´   s,    +	.'$t   verticali   c         C   s|  d d l  } t |  d | d d ƒ\ }  } t |  ƒ d k r@ i  Sd } | | } | d | d f }	 t | ƒ }
 t |  ƒ |
 } t |
 ƒ t | ƒ } | d k r~| j d t |
 ƒ ƒ } | j | t | ƒ ƒ } | j d | t |
 ƒ ƒ } | j d | t | ƒ ƒ } | j | | g ƒ |	 } | j | | g ƒ |	 } | j | | g ƒ } t	 | d	 | ƒ| } t
 t | | ƒ ƒ } | S| d
 k rf| j | t |
 ƒ ƒ } | j d t | ƒ ƒ } | j d | t |
 ƒ ƒ } | j d | t | ƒ ƒ } | j | | g ƒ |	 } | j | | g ƒ |	 } | j | | g ƒ } t	 | d	 | ƒ| } t
 t | | ƒ ƒ } | Sd } t | ƒ ‚ d S(   s  Position nodes in two straight lines.

    Parameters
    ----------
    G : NetworkX graph or list of nodes
        A position will be assigned to every node in G.

    nodes : list or container
        Nodes in one node set of the bipartite graph.
        This set will be placed on left or top.

    align : string (default='vertical')
        The alignment of nodes. Vertical or horizontal.

    scale : number (default: 1)
        Scale factor for positions.

    center : array-like or None
        Coordinate pair around which to center the layout.

    aspect_ratio : number (default=4/3):
        The ratio of the width to the height of the layout.

    Returns
    -------
    pos : dict
        A dictionary of positions keyed by node.

    Examples
    --------
    >>> G = nx.bipartite.gnmk_random_graph(3, 5, 10, seed=123)
    >>> top = nx.bipartite.sets(G)[0]
    >>> pos = nx.bipartite_layout(G, top)

    Notes
    -----
    This algorithm currently only works in two dimensions and does not
    try to minimize edge crossings.

    iÿÿÿÿNR   R   i   i    i   R4   R#   t
   horizontals,   align must be either vertical or horizontal.(   R   R   R   t   setR.   t   repeatR'   R)   t   concatenateR   R   R    R   (   R   R3   t   alignR#   R   t   aspect_ratioR   t   heightt   widtht   offsett   topt   bottomt   left_xst   right_xst   left_yst   right_yst   top_post
   bottom_posR"   t   top_yst	   bottom_yst   top_xst	   bottom_xsR   (    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyR     sD    +
i
   i2   g-Cëâ6?t   weightc      	   C   s»  d d l  } t |  | |	 ƒ \ }  } | d k	 rz t t |  t t |  ƒ ƒ ƒ ƒ } | j g  | D] } | | ^ q^ ƒ } n  | d k	 rt d „  | j	 ƒ  Dƒ ƒ } | d k r· d } n  |
 j
 t |  ƒ |	 ƒ | | } xI t |  ƒ D]2 \ } } | | k rä | j | | ƒ | | <qä qä Wn d } t |  ƒ d k r9i  St |  ƒ d k rhi | t j j |  j ƒ  ƒ 6Sy˜ t |  ƒ d k  r†t ‚ n  t j |  d | d d	 ƒ} | d k rÞ| d k	 rÞ| j \ } } | | j | ƒ } n  t | | | | | | |	 |
 ƒ } Wnz t j |  d | ƒ} | d k rX| d k	 rX| j \ } } | | j | ƒ } n  t | | | | | | |	 |
 ƒ } n X| d k r¢t | d
 | ƒ| } n  t t |  | ƒ ƒ } | S(   se  Position nodes using Fruchterman-Reingold force-directed algorithm.

    Parameters
    ----------
    G : NetworkX graph or list of nodes
        A position will be assigned to every node in G.

    k : float (default=None)
        Optimal distance between nodes.  If None the distance is set to
        1/sqrt(n) where n is the number of nodes.  Increase this value
        to move nodes farther apart.

    pos : dict or None  optional (default=None)
        Initial positions for nodes as a dictionary with node as keys
        and values as a coordinate list or tuple.  If None, then use
        random initial positions.

    fixed : list or None  optional (default=None)
        Nodes to keep fixed at initial position.

    iterations : int  optional (default=50)
        Maximum number of iterations taken

    threshold: float optional (default = 1e-4)
        Threshold for relative error in node position changes.
        The iteration stops if the error is below this threshold.

    weight : string or None   optional (default='weight')
        The edge attribute that holds the numerical value used for
        the edge weight.  If None, then all edge weights are 1.

    scale : number (default: 1)
        Scale factor for positions. Not used unless `fixed is None`.

    center : array-like or None
        Coordinate pair around which to center the layout.
        Not used unless `fixed is None`.

    dim : int
        Dimension of layout.

    seed : int, RandomState instance or None  optional (default=None)
        Set the random state for deterministic node layouts.
        If int, `seed` is the seed used by the random number generator,
        if numpy.random.RandomState instance, `seed` is the random
        number generator,
        if None, the random number generator is the RandomState instance used
        by numpy.random.

    Returns
    -------
    pos : dict
        A dictionary of positions keyed by node

    Examples
    --------
    >>> G = nx.path_graph(4)
    >>> pos = nx.spring_layout(G)

    # The same using longer but equivalent function name
    >>> pos = nx.fruchterman_reingold_layout(G)
    iÿÿÿÿNc         s   s"   |  ] } | D] } | Vq q d  S(   N(    (   t   .0t   pos_tupt   coord(    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pys	   <genexpr>°  s    i    i   iô  RJ   t   dtypet   fR#   (   R   R   R   R   R    t   rangeR   R   R$   t   valuesR   t	   enumerateR   R%   R&   R3   R   t   to_scipy_sparse_matrixt   shapet   sqrtt   _sparse_fruchterman_reingoldt   to_numpy_arrayt   _fruchterman_reingoldR   (   R   t   kR"   t   fixedt
   iterationst	   thresholdRJ   R#   R   R   R!   R   t   nfixedt   vt   dom_sizet   pos_arrt   it   nt   At   nnodest   _(    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyR
   \  sN    J!)	 !	i   c         C   s¢  d d  l  } y |  j \ }	 }
 Wn& t k
 rG d } t j | ƒ ‚ n X| d  k r{ | j | j |	 | ƒ d |  j ƒ} n | j	 |  j ƒ } | d  k r¯ | j
 d |	 ƒ } n  t t | j d ƒ t | j d ƒ t | j d ƒ t | j d ƒ ƒ d } | t | d ƒ } | j | j d | j d | j d f d |  j ƒ} xSt | ƒ D]E} | d  d  … | j d  d  … f | | j d  d  … d  d  … f } | j j | d d ƒ} | j | d	 d  d
 | ƒ| j d | | | | d |  | | ƒ } | j j | d d ƒ} | j | d	 k  d | ƒ } | j d | | | ƒ } | d  k	 r`d | | <n  | | 7} | | 8} | j j | ƒ |	 } | | k  rUPqUqUW| S(   Niÿÿÿÿs9   fruchterman_reingold() takes an adjacency matrix as inputRN   g      ð?i    i   gš™™™™™¹?t   axisg{®Gáz„?t   outs
   ijk,ij->iki   s   ij,i->ijg        (   R   RT   t   AttributeErrorR   t   NetworkXErrorR   R   R   RN   R   RU   R$   t   Tt   mint   floatR   RP   t   newaxist   linalgt   normt   clipt   einsumt   where(   Rc   RY   R"   RZ   R[   R\   R   R!   R   Rd   Re   R   t   tt   dtt   deltat	   iterationt   distancet   displacementt   lengtht	   delta_post   err(    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyRX   Ý  s@    'O6B	!

c      	   C   s/  d d  l  } y |  j \ }	 }
 Wn& t k
 rG d } t j | ƒ ‚ n Xy d d l m } m } Wn# t k
 r‡ d } t | ƒ ‚ n Xy |  j	 ƒ  }  Wn | |  ƒ j	 ƒ  }  n X| d  k rç | j | j |	 | ƒ d |  j ƒ} n | j |  j ƒ } | d  k rg  } n  | d  k r0| j d |	 ƒ } n  t t | j d ƒ t | j d ƒ t | j d ƒ t | j d ƒ ƒ d	 } | t | d ƒ } | j | |	 f ƒ } x€t | ƒ D]r} | d 9} xÚ t |  j d ƒ D]Å } | | k rñqÙn  | | | j } | j | d
 j d d ƒ ƒ } | j | d k  d | ƒ } | j |  j | ƒ j ƒ  ƒ } | d  d  … | f c | | | | d
 | | | j d d ƒ 7<qÙW| j | d
 j d d ƒ ƒ } | j | d k  d	 | ƒ } | | | j } | | 7} | | 8} | j j | ƒ |	 } | | k  rµPqµqµW| S(   Niÿÿÿÿs9   fruchterman_reingold() takes an adjacency matrix as input(   t   spdiagst
   coo_matrixs>   _sparse_fruchterman_reingold() scipy numpy: http://scipy.org/ RN   g      ð?i    i   gš™™™™™¹?i   Rf   g{®Gáz„?(   R   RT   Rh   R   Ri   t   scipy.sparseR|   R}   t   ImportErrort   tolilR   R   R   RN   R   RU   R$   Rj   Rk   Rl   R   RP   t   sumRr   t
   getrowviewt   toarrayRn   Ro   (   Rc   RY   R"   RZ   R[   R\   R   R!   R   Rd   Re   R   R|   R}   Rs   Rt   Rx   Rv   Ra   Ru   Rw   t   AiRy   Rz   R{   (    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyRV     sZ    '	O
2

c         C   s¬  d d l  } t |  | | ƒ \ }  } t |  ƒ } | d k rZ t t j |  d | ƒƒ } n  d | j | | f ƒ }	 xw t |  ƒ D]i \ }
 } | | k rž q€ n  | | } x> t |  ƒ D]0 \ } } | | k rÓ qµ n  | | |	 |
 | <qµ Wq€ W| d k rK| d k rt	 |  d | ƒ} qKd „  t
 |  | j d d	 t |  ƒ ƒ ƒ Dƒ } n  | j g  |  D] } | | ^ qXƒ } t |	 | | ƒ } t | d
 | ƒ| } t t
 |  | ƒ ƒ S(   sä  Position nodes using Kamada-Kawai path-length cost-function.

    Parameters
    ----------
    G : NetworkX graph or list of nodes
        A position will be assigned to every node in G.

    dist : float (default=None)
        A two-level dictionary of optimal distances between nodes,
        indexed by source and destination node.
        If None, the distance is computed using shortest_path_length().

    pos : dict or None  optional (default=None)
        Initial positions for nodes as a dictionary with node as keys
        and values as a coordinate list or tuple.  If None, then use
        circular_layout() for dim >= 2 and a linear layout for dim == 1.

    weight : string or None   optional (default='weight')
        The edge attribute that holds the numerical value used for
        the edge weight.  If None, then all edge weights are 1.

    scale : number (default: 1)
        Scale factor for positions.

    center : array-like or None
        Coordinate pair around which to center the layout.

    dim : int
        Dimension of layout.

    Returns
    -------
    pos : dict
        A dictionary of positions keyed by node

    Examples
    --------
    >>> G = nx.path_graph(4)
    >>> pos = nx.kamada_kawai_layout(G)
    iÿÿÿÿNRJ   g    €„.Ai   R   c         S   s   i  |  ] \ } } | | “ q S(    (    (   RK   Rb   t   pt(    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pys
   <dictcomp>«  s   	 i    i   R#   (   R   R   R   R   R   R   t   shortest_path_lengtht   onesRR   R   R    R'   t   arrayt   _kamada_kawai_solveR   (   R   t   distR"   RJ   R#   R   R   R   t   nNodest   dist_mtxt   rowt   nrt   rdistt   colt   ncRb   R`   (    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyR   h  s,    .
1&c      	   C   s   d d  l  } d d l m } d } | d |  | j |  j d ƒ d | | f } | t | j ƒ  d d d | d	 t ƒ} | j j	 d | f ƒ S(
   Niÿÿÿÿ(   t   minimizegü©ñÒMbP?i   i    t   methods   L-BFGS-Bt   argst   jac(
   R   t   scipy.optimizeR’   t   eyeRT   t   _kamada_kawai_costfnt   ravelt   Truet   xt   reshape(   RŒ   R`   R   R   R’   t   meanwtt   costargst	   optresult(    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyR‰   ´  s    "c         C   s^  | j  d } |  j | | f ƒ } | d  d  … | j d  d  … f | | j d  d  … d  d  … f } | j j | d d ƒ} | j d | d | | j | ƒ d ƒ }	 | | d }
 d |
 | j | ƒ <d | j |
 d	 ƒ } | j d
 | |
 |	 ƒ | j d | |
 |	 ƒ } | j | d d ƒ} | d | | j | d	 ƒ 7} | | | 7} | | j	 ƒ  f S(   Ni    Rf   iÿÿÿÿs   ijk,ij->ijki   gü©ñÒMbP?g      ð?g      à?i   s   ij,ij,ijk->iks   ij,ij,ijk->jk(
   RT   Rœ   Rm   Rn   Ro   Rq   R—   t   diag_indicesR   R™   (   t   pos_vecR   t   invdistt
   meanweightR   R‹   R`   Ru   t   nodesept	   directionR=   t   costt   gradt   sumpos(    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyR˜   Æ  s     B	c         C   s°  d d l  } t |  | | ƒ \ }  } t |  ƒ d k r¿ t |  ƒ d k rZ | j g  ƒ } nR t |  ƒ d k r | j | g ƒ } n+ | j | j | ƒ | j | ƒ d g ƒ } t t |  | ƒ ƒ Syk t |  ƒ d k  rÝ t ‚ n  t j	 |  d | d	 d
 ƒ} |  j
 ƒ  r| | j | ƒ } n  t | | ƒ } WnW t t f k
 rƒt j |  d | ƒ} |  j
 ƒ  rq| | j 7} n  t | | ƒ } n Xt | | ƒ | } t t |  | ƒ ƒ } | S(   sÔ  Position nodes using the eigenvectors of the graph Laplacian.

    Parameters
    ----------
    G : NetworkX graph or list of nodes
        A position will be assigned to every node in G.

    weight : string or None   optional (default='weight')
        The edge attribute that holds the numerical value used for
        the edge weight.  If None, then all edge weights are 1.

    scale : number (default: 1)
        Scale factor for positions.

    center : array-like or None
        Coordinate pair around which to center the layout.

    dim : int
        Dimension of layout.

    Returns
    -------
    pos : dict
        A dictionary of positions keyed by node

    Examples
    --------
    >>> G = nx.path_graph(4)
    >>> pos = nx.spectral_layout(G)

    Notes
    -----
    Directed graphs will be considered as undirected graphs when
    positioning the nodes.

    For larger graphs (>500 nodes) this will use the SciPy sparse
    eigenvalue solver (ARPACK).
    iÿÿÿÿNi   i    i   g       @iô  RJ   RN   t   d(   R   R   R   Rˆ   R   R   R    R   R   RS   t   is_directedt	   transposet   _sparse_spectralR   RW   Rj   t	   _spectralR   (   R   RJ   R#   R   R   R   R"   Rc   (    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyR	   à  s0    (+	c         C   sÒ   d d  l  } y |  j \ } } Wn& t k
 rG d } t j | ƒ ‚ n X| j | d |  j ƒ} | | j |  d d ƒ} | |  } | j j	 | ƒ \ }	 }
 | j
 |	 ƒ d | d !} | j |
 d  d  … | f ƒ S(   Niÿÿÿÿs-   spectral() takes an adjacency matrix as inputRN   Rf   i   (   R   RT   Rh   R   Ri   t   identityRN   R   Rn   t   eigt   argsortt   real(   Rc   R   R   Rd   Re   R   t   It   Dt   Lt   eigenvaluest   eigenvectorst   index(    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyR­   *  s    
c         C   s)  d d  l  } d d l m } d d l m } y |  j \ } } Wn& t k
 rg d } t j | ƒ ‚ n X| j	 |  j
 d d ƒ j ƒ } | | d | | ƒ }	 |	 |  }
 | d } t d | d t | j | ƒ ƒ ƒ } | |
 | d	 d
 d | ƒ\ } } | j | ƒ d | !} | j | d  d  … | f ƒ S(   Niÿÿÿÿ(   R|   (   t   eigshs4   sparse_spectral() takes an adjacency matrix as inputRf   i   i    i   t   whicht   SMt   ncv(   R   R~   R|   t   scipy.sparse.linalg.eigenR¸   RT   Rh   R   Ri   R   R   Rj   R$   t   intRU   R°   R±   (   Rc   R   R   R|   R¸   Rd   Re   R   t   dataR³   R´   RY   R»   Rµ   R¶   R·   (    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyR¬   @  s     

&!c         C   sÒ   d } xx t  |  j d ƒ D]c } |  d d … | f c |  d d … | f j ƒ  8<t t |  d d … | f ƒ j ƒ  | ƒ } q W| d k rÎ x> t  |  j d ƒ D]& } |  d d … | f c | | 9<q¡ Wn  |  S(   sX  Return scaled position array to (-scale, scale) in all axes.

    The function acts on NumPy arrays which hold position information.
    Each position is one row of the array. The dimension of the space
    equals the number of columns. Each coordinate in one column.

    To rescale, the mean (center) is subtracted from each axis separately.
    Then all values are scaled so that the largest magnitude value
    from all axes equals `scale` (thus, the aspect ratio is preserved).
    The resulting NumPy Array is returned (order of rows unchanged).

    Parameters
    ----------
    pos : numpy array
        positions to be scaled. Each row is a position.

    scale : number (default: 1)
        The size of the resulting extent in all directions.

    Returns
    -------
    pos : numpy array
        scaled positions. Each row is a position.

    i    i   N(   RP   RT   t   meanR$   t   abs(   R"   R#   t   limRa   (    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyR   \  s    2/'c         C   s`   d d l  m } y d d  l } Wn | d ƒ ‚ n Xy d d  l } Wn | d ƒ ‚ n Xd  S(   Niÿÿÿÿ(   t   SkipTests   NumPy not availables   SciPy not available(   t   noseRÂ   R   t   scipy(   t   moduleRÂ   R   RÄ   (    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyt   setup_moduleƒ  s    gUUUUUUõ?(   t   __doc__t
   __future__R    t   networkxR   t   networkx.utilsR   t   __all__R   R   R   R   R   R   R
   R   RX   RV   R   R‰   R˜   R	   R­   R¬   R   RÆ   (    (    (    s6   lib/python2.7/site-packages/networkx/drawing/layout.pyt   <module>   sf   			0COX	s	<			JG		J'