ó
mÜJ]c           @   s
  d  d l  m Z d  d l m Z m Z m Z m Z m Z m Z d  d l	 m
 Z
 d  d l m Z d Z e d e
 f d „  ƒ  Yƒ Z d
 e f d „  ƒ  YZ d „  Z e d e
 f d „  ƒ  Yƒ Z d	 e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z d S(   i   (   t   abstract(   t   Anyt   Dictt   Eithert   Intt   Seqt   String(   t   Model(   t   ColumnDataSourcet   EdgesAndLinkedNodest   GraphHitTestPolicyt   LayoutProvidert   NodesAndLinkedEdgest	   NodesOnlyt   StaticLayoutProviderc           B   s   e  Z d  Z RS(   s   

    (   t   __name__t
   __module__t   __doc__(    (    (    s2   lib/python2.7/site-packages/bokeh/models/graphs.pyR   +   s   c           B   s8   e  Z d  Z e e e e ƒ e e ƒ d i  d d ƒZ	 RS(   s   

    t   defaultt   helpsV  
    The coordinates of the graph nodes in cartesian space. The dictionary
    keys correspond to a node index and the values are a two element sequence
    containing the x and y coordinates of the node.

    .. code-block:: python

        {
            0 : [0.5, 0.5],
            1 : [1.0, 0.86],
            2 : [0.86, 1],
        }
    (
   R   R   R   R   R   R   R   R   R   t   graph_layout(    (    (    s2   lib/python2.7/site-packages/bokeh/models/graphs.pyR   4   s   !c         K   sH  d d l  m } d d l m } t ƒ  } g  t |  j d t ƒ ƒ D]# } | d j ƒ  D] } | ^ qV qB } t t	 | ƒ ƒ } xk | D]c } g  |  j d t ƒ D]. \ }	 }
 | |
 j ƒ  k rÅ |
 | n d ^ q } t | ƒ } | | | <q„ Wd | k rd d l m } | d	 ƒ n  t |  j ƒ  ƒ | d <t ƒ  } g  |  j d t ƒ D]# } | d j ƒ  D] } | ^ qZqF} t t	 | ƒ ƒ } xn | D]f } g  |  j d t ƒ D]1 \ }	 }	 } | | j ƒ  k rÌ| | n d ^ q¡} t | ƒ } | | | <qˆWd
 | k s
d | k r'd d l m } | d ƒ n  g  |  j ƒ  D] } | d ^ q4| d
 <g  |  j ƒ  D] } | d ^ q[| d <t d | ƒ } t d | ƒ } | ƒ  } | j | j j _ | j | j j _ t | ƒ rÞ| |  |  } nT | } | j j j d } t	 | ƒ t	 | j ƒ  ƒ k r2d d l m } | d ƒ n  | d | ƒ | _ | S(   s*  
        Generate a ``GraphRenderer`` from a ``networkx.Graph`` object and networkx
        layout function. Any keyword arguments will be passed to the
        layout function.

        Only two dimensional layouts are supported.

        Args:
            graph (networkx.Graph) : a networkx graph to render
            layout_function (function or dict) : a networkx layout function or mapping of node keys to positions.
            The position is a two element sequence containing the x and y coordinate.

        Returns:
            instance (GraphRenderer)

        .. note::
            Node and edge attributes may be lists or tuples. However, a given
            attribute must either have *all* lists or tuple values, or *all*
            scalar values, for nodes or edges it is defined on.

        .. warning::
            Node attributes labeled 'index' and edge attributes labeled 'start' or 'end' are ignored.
            If you want to convert these attributes, please re-label them to other names.

        Raises:
            ValueError

        i   (   t   GraphRenderer(   R   t   datai   t   indexiÿÿÿÿ(   t   warns‚   Converting node attributes labeled 'index' are skipped. If you want to convert these attributes, please re-label with other names.t   startt   ends   Converting edge attributes labeled 'start' or 'end' are skipped. If you want to convert these attributes, please re-label them with other names.i    sn   Node keys in 'layout_function' don't match node keys in the graph. These nodes may not be displayed correctly.R   N(   t   models.renderersR   t   models.graphsR   t   dictt   listt   nodest   Truet   keyst   sett   Nonet   _handle_sublistst   warningsR   t   edgesR   R   t   node_renderert   data_sourcet   edge_renderert   callablet   layout_provider(   t   grapht   layout_functiont   kwargsR   R   t	   node_dictt   nodet   attr_keyt   node_attr_keyst   _t	   node_attrt   valuesR   t	   edge_dictt   edget   edge_attr_keyst	   edge_attrt   xt   node_sourcet   edge_sourcet   graph_rendererR   t	   node_keys(    (    s2   lib/python2.7/site-packages/bokeh/models/graphs.pyt   from_networkxG   sV    	#D	#G''	c           B   s   e  Z d  Z RS(   s   

    (   R   R   R   (    (    (    s2   lib/python2.7/site-packages/bokeh/models/graphs.pyR
   ¬   s   c           B   s   e  Z d  Z RS(   s™   
    With the ``NodesOnly`` policy, only graph nodes are able to be selected and
    inspected. There is no selection or inspection of graph edges.

    (   R   R   R   (    (    (    s2   lib/python2.7/site-packages/bokeh/models/graphs.pyR   µ   s   c           B   s   e  Z d  Z RS(   s÷   
    With the ``NodesAndLinkedEdges`` policy, inspection or selection of graph
    nodes will result in the inspection or selection of the node and of the
    linked graph edges. There is no direct selection or inspection of graph
    edges.

    (   R   R   R   (    (    (    s2   lib/python2.7/site-packages/bokeh/models/graphs.pyR   ¾   s   c           B   s   e  Z d  Z RS(   s÷   
    With the ``EdgesAndLinkedNodes`` policy, inspection or selection of graph
    edges will result in the inspection or selection of the edge and of the
    linked graph nodes. There is no direct selection or inspection of graph
    nodes.

    (   R   R   R   (    (    (    s2   lib/python2.7/site-packages/bokeh/models/graphs.pyR	   É   s   c         C   sn   t  d „  |  Dƒ ƒ rj t d „  |  Dƒ ƒ s; t d ƒ ‚ n  g  |  D]$ } | d  k rZ g  n	 t | ƒ ^ qB S|  S(   Nc         s   s$   |  ] } t  | t t f ƒ Vq d  S(   N(   t
   isinstanceR   t   tuple(   t   .0R:   (    (    s2   lib/python2.7/site-packages/bokeh/models/graphs.pys	   <genexpr>Ú   s    c         s   s0   |  ]& } | d  k	 r t | t t f ƒ Vq d  S(   N(   R#   R@   R   RA   (   RB   R:   (    (    s2   lib/python2.7/site-packages/bokeh/models/graphs.pys	   <genexpr>Û   s    s;   Can't mix scalar and non-scalar values for graph attributes(   t   anyt   allt
   ValueErrorR#   R   (   R5   R:   (    (    s2   lib/python2.7/site-packages/bokeh/models/graphs.pyR$   Ø   s
    /N(   R	   R
   R   R   R   R   (   t   core.has_propsR    t   core.propertiesR   R   R   R   R   R   t   modelR   t   models.sourcesR   t   __all__R   R   R?   R
   R   R   R	   R$   (    (    (    s2   lib/python2.7/site-packages/bokeh/models/graphs.pyt   <module>   s&   .     	e	