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

Draw networks with matplotlib.

See Also
--------

matplotlib:     http://matplotlib.org/

pygraphviz:     http://pygraphviz.github.io/

iN(   t   is_string_like(   t   shell_layoutt   circular_layoutt   kamada_kawai_layoutt   spectral_layoutt   spring_layoutt   random_layoutt   drawt   draw_networkxt   draw_networkx_nodest   draw_networkx_edgest   draw_networkx_labelst   draw_networkx_edge_labelst   draw_circulart   draw_kamada_kawait   draw_randomt   draw_spectralt   draw_springt
   draw_shellc         K   s  y d d l  j } Wn5 t k
 r2 t d   n t k
 rJ d GH  n X| d k rf | j   } n | j   } | j d  | d k r | j   d k r | j	 d  } q | j
   } n  d | k r d	 | k | d <n  y1 t |  d
 | d | | | j   | j   Wn
   n Xd S(   sw  Draw the graph G with Matplotlib.

    Draw the graph as a simple representation with no node
    labels or edge labels and using the full Matplotlib figure area
    and no axis labels by default.  See draw_networkx() for more
    full-featured drawing that allows title, axis labels etc.

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

    pos : dictionary, optional
       A dictionary with nodes as keys and positions as values.
       If not specified a spring layout positioning will be computed.
       See :py:mod:`networkx.drawing.layout` for functions that
       compute node positions.

    ax : Matplotlib Axes object, optional
       Draw the graph in specified Matplotlib axes.

    kwds : optional keywords
       See networkx.draw_networkx() for a description of optional keywords.

    Examples
    --------
    >>> G = nx.dodecahedral_graph()
    >>> nx.draw(G)
    >>> nx.draw(G, pos=nx.spring_layout(G))  # use spring layout

    See Also
    --------
    draw_networkx()
    draw_networkx_nodes()
    draw_networkx_edges()
    draw_networkx_labels()
    draw_networkx_edge_labels()

    Notes
    -----
    This function has the same name as pylab.draw and pyplot.draw
    so beware when using

    >>> from networkx import *

    since you might overwrite the pylab.draw function.

    With pyplot use

    >>> import matplotlib.pyplot as plt
    >>> import networkx as nx
    >>> G = nx.dodecahedral_graph()
    >>> nx.draw(G)  # networkx draw()
    >>> plt.draw()  # pyplot draw()

    Also see the NetworkX drawing examples at
    https://networkx.github.io/documentation/latest/auto_examples/index.html
    iNs   Matplotlib required for draw()s!   Matplotlib unable to open displayt   wi    i   t   with_labelst   labelst   post   ax(   i    i    i   i   (   t   matplotlib.pyplott   pyplott   ImportErrort   RuntimeErrort   Nonet   gcft
   get_figuret   set_facecolort   _axstackt   add_axest   gcaR   t   set_axis_offt   draw_if_interactive(   t   GR   R   t   kwdst   pltt   cf(    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyR   ,   s0    ;
c         K   s   y d d l  j } Wn5 t k
 r2 t d   n t k
 rJ d GH  n X| d k rl t j j |   } n  t |  | |  } t	 |  | d | | } | r t
 |  | |  n  | j   d S(   s)  Draw the graph G using Matplotlib.

    Draw the graph with Matplotlib with options for node positions,
    labeling, titles, and many other drawing features.
    See draw() for simple drawing without labels or axes.

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

    pos : dictionary, optional
       A dictionary with nodes as keys and positions as values.
       If not specified a spring layout positioning will be computed.
       See :py:mod:`networkx.drawing.layout` for functions that
       compute node positions.

    arrows : bool, optional (default=True)
       For directed graphs, if True draw arrowheads.
       Note: Arrows will be the same color as edges.

    arrowstyle : str, optional (default='-|>')
        For directed graphs, choose the style of the arrowsheads.
        See :py:class: `matplotlib.patches.ArrowStyle` for more
        options.

    arrowsize : int, optional (default=10)
       For directed graphs, choose the size of the arrow head head's length and
       width. See :py:class: `matplotlib.patches.FancyArrowPatch` for attribute
       `mutation_scale` for more info.

    with_labels :  bool, optional (default=True)
       Set to True to draw labels on the nodes.

    ax : Matplotlib Axes object, optional
       Draw the graph in the specified Matplotlib axes.

    nodelist : list, optional (default G.nodes())
       Draw only specified nodes

    edgelist : list, optional (default=G.edges())
       Draw only specified edges

    node_size : scalar or array, optional (default=300)
       Size of nodes.  If an array is specified it must be the
       same length as nodelist.

    node_color : color string, or array of floats, (default='r')
       Node color. Can be a single color format string,
       or a  sequence of colors with the same length as nodelist.
       If numeric values are specified they will be mapped to
       colors using the cmap and vmin,vmax parameters.  See
       matplotlib.scatter for more details.

    node_shape :  string, optional (default='o')
       The shape of the node.  Specification is as matplotlib.scatter
       marker, one of 'so^>v<dph8'.

    alpha : float, optional (default=1.0)
       The node and edge transparency

    cmap : Matplotlib colormap, optional (default=None)
       Colormap for mapping intensities of nodes

    vmin,vmax : float, optional (default=None)
       Minimum and maximum for node colormap scaling

    linewidths : [None | scalar | sequence]
       Line width of symbol border (default =1.0)

    width : float, optional (default=1.0)
       Line width of edges

    edge_color : color string, or array of floats (default='r')
       Edge color. Can be a single color format string,
       or a sequence of colors with the same length as edgelist.
       If numeric values are specified they will be mapped to
       colors using the edge_cmap and edge_vmin,edge_vmax parameters.

    edge_cmap : Matplotlib colormap, optional (default=None)
       Colormap for mapping intensities of edges

    edge_vmin,edge_vmax : floats, optional (default=None)
       Minimum and maximum for edge colormap scaling

    style : string, optional (default='solid')
       Edge line style (solid|dashed|dotted,dashdot)

    labels : dictionary, optional (default=None)
       Node labels in a dictionary keyed by node of text labels

    font_size : int, optional (default=12)
       Font size for text labels

    font_color : string, optional (default='k' black)
       Font color string

    font_weight : string, optional (default='normal')
       Font weight

    font_family : string, optional (default='sans-serif')
       Font family

    label : string, optional
        Label for graph legend

    Notes
    -----
    For directed graphs, arrows  are drawn at the head end.  Arrows can be
    turned off with keyword arrows=False.

    Examples
    --------
    >>> G = nx.dodecahedral_graph()
    >>> nx.draw(G)
    >>> nx.draw(G, pos=nx.spring_layout(G))  # use spring layout

    >>> import matplotlib.pyplot as plt
    >>> limits = plt.axis('off')  # turn of axis

    Also see the NetworkX drawing examples at
    https://networkx.github.io/documentation/latest/auto_examples/index.html

    See Also
    --------
    draw()
    draw_networkx_nodes()
    draw_networkx_edges()
    draw_networkx_labels()
    draw_networkx_edge_labels()
    iNs   Matplotlib required for draw()s!   Matplotlib unable to open displayt   arrows(   R   R   R   R   R   t   nxt   drawingR   R	   R
   R   R$   (   R%   R   R)   R   R&   R'   t   node_collectiont   edge_collection(    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyR      s    i,  t   rt   og      ?c         K   s  d d l  } y d d l j } d d l } Wn5 t k
 rJ t d   n t k
 rb d GH  n X|
 d k r~ | j   }
 n  | d k r t |   } n  | s t	 |  d k r d Sy* | j
 g  | D] } | | ^ q  } WnE t k
 r} t j d |   n  t k
 r't j d   n Xt | | j  r^t | | | | | |	  } d } n  |
 j | d d  d f | d d  d f d	 | d
 | d | d | d | d |	 d | d | d | d | 
} | j d  | S(   sU	  Draw the nodes of the graph G.

    This draws only the nodes of the graph G.

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

    pos : dictionary
       A dictionary with nodes as keys and positions as values.
       Positions should be sequences of length 2.

    ax : Matplotlib Axes object, optional
       Draw the graph in the specified Matplotlib axes.

    nodelist : list, optional
       Draw only specified nodes (default G.nodes())

    node_size : scalar or array
       Size of nodes (default=300).  If an array is specified it must be the
       same length as nodelist.

    node_color : color string, or array of floats
       Node color. Can be a single color format string (default='r'),
       or a  sequence of colors with the same length as nodelist.
       If numeric values are specified they will be mapped to
       colors using the cmap and vmin,vmax parameters.  See
       matplotlib.scatter for more details.

    node_shape :  string
       The shape of the node.  Specification is as matplotlib.scatter
       marker, one of 'so^>v<dph8' (default='o').

    alpha : float or array of floats
       The node transparency.  This can be a single alpha value (default=1.0),
       in which case it will be applied to all the nodes of color. Otherwise,
       if it is an array, the elements of alpha will be applied to the colors
       in order (cycling through alpha multiple times if necessary).

    cmap : Matplotlib colormap
       Colormap for mapping intensities of nodes (default=None)

    vmin,vmax : floats
       Minimum and maximum for node colormap scaling (default=None)

    linewidths : [None | scalar | sequence]
       Line width of symbol border (default =1.0)

    edgecolors : [None | scalar | sequence]
       Colors of node borders (default = node_color)

    label : [None| string]
       Label for legend

    Returns
    -------
    matplotlib.collections.PathCollection
        `PathCollection` of the nodes.

    Examples
    --------
    >>> G = nx.dodecahedral_graph()
    >>> nodes = nx.draw_networkx_nodes(G, pos=nx.spring_layout(G))

    Also see the NetworkX drawing examples at
    https://networkx.github.io/documentation/latest/auto_examples/index.html

    See Also
    --------
    draw()
    draw_networkx()
    draw_networkx_edges()
    draw_networkx_labels()
    draw_networkx_edge_labels()
    iNs   Matplotlib required for draw()s!   Matplotlib unable to open displayi    s   Node %s has no position.s   Bad value in node positions.i   t   st   ct   markert   cmapt   vmint   vmaxt   alphat
   linewidthst
   edgecolorst   labeli   (   t   collectionsR   R   t   numpyR   R   R   R"   t   listt   lent   asarrayt   KeyErrorR*   t   NetworkXErrort
   ValueErrort
   isinstancet   Iterablet   apply_alphat   scattert
   set_zorder(   R%   R   t   nodelistt	   node_sizet
   node_colort
   node_shapeR6   R3   R4   R5   R   R7   R8   R9   R&   R:   R'   t   npt   vt   xyt   eR,   (    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyR	     sJ    Z*	/	t   kt   solids   -|>i
   c   @         sn  yv d d l  } d d l j } d d l j } d d l m } m } m } d d l	 m
 } d d l m } d d l   Wn5 t k
 r t d   n t k
 r d GH  n X| d k r | j   } n  | d k r t |  j    } n  | st |  d k rd S| d k r(t |  j    } n    j g  | D]" } | | d | | d	 f ^ q5 } | j |  s{| f } n | } t |  r| j |  rt |  t |  k r  j g  | D] } t |  ^ q rt g  | D] } | j | |  ^ q } q  j g  | D] } t |  ^ q r  j g  | D]' } | j |  oet |  d k ^ qA rt |  } qd } qt d   nH t |  st |  d	 k r| j | |  f } n d }  t |    |  j   s| r| | d | d | d d d | d | j }! |! j d	  |! j  |  | j! |!  | j" |  rg|! j# |  n  | d k r|	 d k	 rt$ |	 |  st%  n  |! j&   j |   |! j' |	  |
 d k	 s| d k	 r|! j( |
 |  q|! j)   n  |! Sd }" |  j   r>| r>  f d   }# g  }" | }$ | }% |% d k r|	 d k	 r_t$ |	 |  skt%  n | j*   }	 |
 d k rt+ |  }
 n  | d k rt, |  } n  | d |
 d |  }& n  xt- |  D]q\ }' \ }( }) |( \ }* }+ |) \ }, }- d }. d }/ d }0 d }1 | j |  rR| |' \ }2 }3 | j. |3  }4 | |4 }5 |# |5 |  }1 n |# | |  }1 |% d k r|	 |& | |'   }. n) t |%  d	 k r|% |' }. n
 |% d }. t |  d	 k r| |' }/ n
 | d }/ | |* |+ f |, |- f d | d |0 d |1 d |$ d |. d |/ d d	 }6 |" j/ |6  | j0 |6  qWn    j1   j2 | d d  d d  d f   }7   j3   j2 | d d  d d  d f   }8   j1   j2 | d d  d d  d	 f   }9   j3   j2 | d d  d d  d	 f   }: |8 |7 }; |: |9 }< d |; d |< }= }> |7 |= |9 |> f |8 |= |: |> f f }? | j4 |?  | j5   |" S(    s  Draw the edges of the graph G.

    This draws only the edges of the graph G.

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

    pos : dictionary
       A dictionary with nodes as keys and positions as values.
       Positions should be sequences of length 2.

    edgelist : collection of edge tuples
       Draw only specified edges(default=G.edges())

    width : float, or array of floats
       Line width of edges (default=1.0)

    edge_color : color string, or array of floats
       Edge color. Can be a single color format string (default='r'),
       or a sequence of colors with the same length as edgelist.
       If numeric values are specified they will be mapped to
       colors using the edge_cmap and edge_vmin,edge_vmax parameters.

    style : string
       Edge line style (default='solid') (solid|dashed|dotted,dashdot)

    alpha : float
       The edge transparency (default=1.0)

    edge_ cmap : Matplotlib colormap
       Colormap for mapping intensities of edges (default=None)

    edge_vmin,edge_vmax : floats
       Minimum and maximum for edge colormap scaling (default=None)

    ax : Matplotlib Axes object, optional
       Draw the graph in the specified Matplotlib axes.

    arrows : bool, optional (default=True)
       For directed graphs, if True draw arrowheads.
       Note: Arrows will be the same color as edges.

    arrowstyle : str, optional (default='-|>')
       For directed graphs, choose the style of the arrow heads.
       See :py:class: `matplotlib.patches.ArrowStyle` for more
       options.

    arrowsize : int, optional (default=10)
       For directed graphs, choose the size of the arrow head head's length and
       width. See :py:class: `matplotlib.patches.FancyArrowPatch` for attribute
       `mutation_scale` for more info.

    label : [None| string]
       Label for legend

    Returns
    -------
    matplotlib.collection.LineCollection
        `LineCollection` of the edges

    list of matplotlib.patches.FancyArrowPatch
        `FancyArrowPatch` instances of the directed edges

    Depending whether the drawing includes arrows or not.

    Notes
    -----
    For directed graphs, arrows are drawn at the head end.  Arrows can be
    turned off with keyword arrows=False. Be sure to include `node_size` as a
    keyword argument; arrows are drawn considering the size of nodes.

    Examples
    --------
    >>> G = nx.dodecahedral_graph()
    >>> edges = nx.draw_networkx_edges(G, pos=nx.spring_layout(G))

    >>> G = nx.DiGraph()
    >>> G.add_edges_from([(1, 2), (1, 3), (2, 3)])
    >>> arcs = nx.draw_networkx_edges(G, pos=nx.spring_layout(G))
    >>> alphas = [0.3, 0.4, 0.5]
    >>> for i, arc in enumerate(arcs):  # change alpha values of arcs
    ...     arc.set_alpha(alphas[i])

    Also see the NetworkX drawing examples at
    https://networkx.github.io/documentation/latest/auto_examples/index.html

    See Also
    --------
    draw()
    draw_networkx()
    draw_networkx_nodes()
    draw_networkx_labels()
    draw_networkx_edge_labels()
    iN(   t   colorConvertert   Colormapt	   Normalize(   t   LineCollection(   t   FancyArrowPatchs   Matplotlib required for draw()s!   Matplotlib unable to open displayi    i   i   i   s.   edge_color must contain color names or numberss8   edge_color must be a color or list of one color per edget   colorsR7   t   antialiasedst	   linestylet   transOffsetc            s6   | d k r!   j  d |   d S  j  |   d Sd  S(   Ns   s^>v<di   (   t   sqrt(   t   marker_sizeR2   (   RK   (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyt   to_marker_edgex  s    R4   R5   t
   arrowstylet   shrinkAt   shrinkBt   mutation_scalet   colort	   linewidtht   zorderg?(   i   i   (   i   (6   t
   matplotlibR   R   t   matplotlib.cbookt   cbookt   matplotlib.colorsRQ   RR   RS   t   matplotlib.collectionsRT   t   matplotlib.patchesRU   R;   R   R   R   R"   R<   t   edgesR=   t   nodesR>   t   iterableR    t   alltruet   tuplet   to_rgbaRA   t   is_directedt	   transDataRF   t	   set_labelt   add_collectiont
   is_numliket	   set_alphaRB   t   AssertionErrort	   set_arrayt   set_cmapt   set_climt	   autoscalet   get_cmapt   mint   maxt	   enumeratet   indext   appendt	   add_patcht   amint   ravelt   amaxt   update_datalimt   autoscale_view(@   R%   R   t   edgelistt   widtht
   edge_colort   styleR6   R]   t	   arrowsizet	   edge_cmapt	   edge_vmint	   edge_vmaxR   R)   R9   RH   RG   RJ   R&   Rd   R'   t   cbRQ   RR   RS   RT   RU   RN   t   edge_post   lwR1   t   edge_colorst   msgR-   t   arrow_collectionR\   R`   t   arrow_colorst   color_normalt   it   srct   dstt   x1t   y1t   x2t   y2t   arrow_colort
   line_widtht   shrink_sourcet   shrink_targett   src_nodet   dst_nodet
   index_nodeR[   t   arrowt   minxt   maxxt   minyt   maxyR   t   ht   padxt   padyt   corners(    (   RK   s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyR
     s    r8(()	4		


	1111

(
i   s
   sans-serift   normalc
         K   st  y" d d l  j } d d l j } Wn5 t k
 rA t d   n t k
 rY d GH  n X|	 d k ru | j   }	 n  | d k r t d   |  j	   D  } n  |
 j
 d d  } |
 j
 d d  } i  } x | j   D] \ } } | | \ } } t |  st |  } n  |	 j | | | d	 | d
 | d | d | d | d | d | d |	 j d | d t 
} | | | <q W| S(   sq  Draw node labels on the graph G.

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

    pos : dictionary
       A dictionary with nodes as keys and positions as values.
       Positions should be sequences of length 2.

    labels : dictionary, optional (default=None)
       Node labels in a dictionary keyed by node of text labels
       Node-keys in labels should appear as keys in `pos`.
       If needed use: `{n:lab for n,lab in labels.items() if n in pos}`

    font_size : int
       Font size for text labels (default=12)

    font_color : string
       Font color string (default='k' black)

    font_family : string
       Font family (default='sans-serif')

    font_weight : string
       Font weight (default='normal')

    alpha : float
       The text transparency (default=1.0)

    ax : Matplotlib Axes object, optional
       Draw the graph in the specified Matplotlib axes.

    Returns
    -------
    dict
        `dict` of labels keyed on the nodes

    Examples
    --------
    >>> G = nx.dodecahedral_graph()
    >>> labels = nx.draw_networkx_labels(G, pos=nx.spring_layout(G))

    Also see the NetworkX drawing examples at
    https://networkx.github.io/documentation/latest/auto_examples/index.html

    See Also
    --------
    draw()
    draw_networkx()
    draw_networkx_nodes()
    draw_networkx_edges()
    draw_networkx_edge_labels()
    iNs   Matplotlib required for draw()s!   Matplotlib unable to open displayc         s   s   |  ] } | | f Vq d  S(   N(    (   t   .0t   n(    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pys	   <genexpr>  s    t   horizontalalignmentt   centert   verticalalignmentt   sizeRa   t   familyt   weightR6   t	   transformt   bboxt   clip_on(   R   R   Re   Rf   R   R   R   R"   t   dictRk   t   gett   itemsR    t   strt   textRq   t   True(   R%   R   R   t	   font_sizet
   font_colort   font_familyt   font_weightR6   R   R   R&   R'   R   R   R   t
   text_itemsR   R9   t   xt   yt   t(    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyR     sB    A		g      ?c          K   s  y d d l  j } d d l } Wn5 t k
 r> t d   n t k
 rV d GH  n X|
 d k rr | j   }
 n  | d k r d   |  j d t  D } n | } i  } x| j	   D]\ \ } } } | | \ } } | | \ } } | | | d | | | | d | } } | r| j
 | | | |  d | j d	 } | d
 k r]| d 8} n  | d k  rv| d 7} n  | j | | f  } |
 j j | j | f  | j d"   d } n d } |	 d k rt d d d d# d d$  }	 n  t |  st |  } n  | j d d  } | j d d  } |
 j | | | d | d | d | d | d | d | d | d | d |
 j d |	 d  d d! t } | | | | f <q W| S(%   s  Draw edge labels.

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

    pos : dictionary
       A dictionary with nodes as keys and positions as values.
       Positions should be sequences of length 2.

    ax : Matplotlib Axes object, optional
       Draw the graph in the specified Matplotlib axes.

    alpha : float
       The text transparency (default=1.0)

    edge_labels : dictionary
       Edge labels in a dictionary keyed by edge two-tuple of text
       labels (default=None). Only labels for the keys in the dictionary
       are drawn.

    label_pos : float
       Position of edge label along edge (0=head, 0.5=center, 1=tail)

    font_size : int
       Font size for text labels (default=12)

    font_color : string
       Font color string (default='k' black)

    font_weight : string
       Font weight (default='normal')

    font_family : string
       Font family (default='sans-serif')

    bbox : Matplotlib bbox
       Specify text box shape and colors.

    clip_on : bool
       Turn on clipping at axis boundaries (default=True)

    Returns
    -------
    dict
        `dict` of labels keyed on the edges

    Examples
    --------
    >>> G = nx.dodecahedral_graph()
    >>> edge_labels = nx.draw_networkx_edge_labels(G, pos=nx.spring_layout(G))

    Also see the NetworkX drawing examples at
    https://networkx.github.io/documentation/latest/auto_examples/index.html

    See Also
    --------
    draw()
    draw_networkx()
    draw_networkx_nodes()
    draw_networkx_edges()
    draw_networkx_labels()
    iNs   Matplotlib required for draw()s!   Matplotlib unable to open displayc         S   s(   i  |  ] \ } } } | | | f  q S(    (    (   R   t   uRL   t   d(    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pys
   <dictcomp>  s   	 t   datag      ?g       @ih  iZ   i   ii   i   i    g        t   boxstylet   roundt   ect   fcR   R   R   R   Ra   R   R   R6   t   rotationR   R   Rc   R   (   i   i   (   g      ?g      ?g      ?(   g      ?g      ?g      ?(   R   R   R;   R   R   R   R"   Rj   R   R   t   arctan2t   pit   arrayRq   t   transform_anglest   reshapeR   R    R   R   R   (    R%   R   t   edge_labelst	   label_posR   R   R   R   R6   R   R   t   rotateR&   R'   RK   R   R   t   n1t   n2R9   R   R   R   R   R   R   t   angleRM   t   trans_angleR   R   R   (    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyR   /  sj    L)		c         K   s   t  |  t |   |  d S(   s8  Draw the graph G with a circular layout.

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

    kwargs : optional keywords
       See networkx.draw_networkx() for a description of optional keywords,
       with the exception of the pos parameter which is not used by this
       function.
    N(   R   R   (   R%   t   kwargs(    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyR     s    c         K   s   t  |  t |   |  d S(   sK  Draw the graph G with a Kamada-Kawai force-directed layout.

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

    kwargs : optional keywords
       See networkx.draw_networkx() for a description of optional keywords,
       with the exception of the pos parameter which is not used by this
       function.
    N(   R   R   (   R%   R   (    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyR     s    c         K   s   t  |  t |   |  d S(   s6  Draw the graph G with a random layout.

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

    kwargs : optional keywords
       See networkx.draw_networkx() for a description of optional keywords,
       with the exception of the pos parameter which is not used by this
       function.
    N(   R   R   (   R%   R   (    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyR     s    c         K   s   t  |  t |   |  d S(   s8  Draw the graph G with a spectral layout.

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

    kwargs : optional keywords
       See networkx.draw_networkx() for a description of optional keywords,
       with the exception of the pos parameter which is not used by this
       function.
    N(   R   R   (   R%   R   (    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyR     s    c         K   s   t  |  t |   |  d S(   s6  Draw the graph G with a spring layout.

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

    kwargs : optional keywords
       See networkx.draw_networkx() for a description of optional keywords,
       with the exception of the pos parameter which is not used by this
       function.
    N(   R   R   (   R%   R   (    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyR      s    c         K   sH   | j  d d  } | d k	 r( | d =n  t |  t |  d | |  d S(   s6  Draw networkx graph with shell layout.

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

    kwargs : optional keywords
       See networkx.draw_networkx() for a description of optional keywords,
       with the exception of the pos parameter which is not used by this
       function.
    t   nlistN(   R   R   R   R   (   R%   R   R   (    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyR     s    
c         C   s+  d d l  } d d l m } m } y/ d d l }	 d d l m }
 d d l j } Wn t	 k
 rp t	 d   n Xt
 |   t
 |  k r t |  d | j  r | j d |  } | j | |  | j |   } n^ y |	 j |
 j |   g  } Wn< t k
 r0|	 j g  |  D] } |
 j |  ^ q } n Xy t
 |  t
 |  k sa| j t
 |  k r| j t
 |  d f  | d | d	 d  d f <| d | d	 d  d	 f <| d | d	 d  d
 f <n  t | | |  t
 |    | d d  d f <Wn' t k
 r&| | d d  d f <n X| S(   s   Apply an alpha (or list of alphas) to the colors provided.

    Parameters
    ----------

    colors : color string, or array of floats
       Color of element. Can be a single color format string (default='r'),
       or a  sequence of colors with the same length as nodelist.
       If numeric values are specified they will be mapped to
       colors using the cmap and vmin,vmax parameters.  See
       matplotlib.scatter for more details.

    alpha : float or array of floats
       Alpha values for elements. This can be a single alpha value, in
       which case it will be applied to all the elements of color. Otherwise,
       if it is an array, the elements of alpha will be applied to the colors
       in order (cycling through alpha multiple times if necessary).

    elem_list : array of networkx objects
       The list of elements which are being colored. These could be nodes,
       edges or labels.

    cmap : matplotlib colormap
       Color map for use if colors is a list of floats corresponding to points
       on a color mapping.

    vmin, vmax : float
       Minimum and maximum values for normalizing colors if a color mapping is
       used.

    Returns
    -------

    rgba_colors : numpy ndarray
        Array containing RGBA format values for each of the node colours.

    iN(   t   islicet   cycle(   RQ   s   Matplotlib required for draw()i    R3   i   i   i   i   (   i    i    (   i    i   (   i    i   (   t   numberst	   itertoolsR   R   R;   Rg   RQ   t   matplotlib.cmt   cmR   R=   RB   t   Numbert   ScalarMappableRy   Ro   R   RA   R   t   resizeR<   t	   TypeError(   RV   R6   t	   elem_listR3   R4   R5   R   R   R   RK   RQ   R   t   mappert   rgba_colorsRa   (    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyRD   #  s6    &.	&-5c         C   s\   d d l  m } y2 d d  l } | j d d t d d  l j } Wn | d   n Xd  S(   Ni(   t   SkipTestt   PSt   warns   matplotlib not available(   t   noseR   Rd   t   uset   FalseR   R   (   t   moduleR   t   mplR'   (    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyt   setup_moduleu  s    (   t   __doc__t   networkxR*   t   networkx.utilsR    t   networkx.drawing.layoutR   R   R   R   R   R   t   __all__R   R   R   R   R	   R
   R   R   R   R   R   R   R   R   RD   R   (    (    (    s8   lib/python2.7/site-packages/networkx/drawing/nx_pylab.pyt   <module>   s   .	Z} d						R