ó
|Ł*^c           @   sś  d  Z  d Z d d d d d d d d	 d
 d d d d d d d d d d d d d d g Z d d l Z d d l m Z m Z m Z m	 Z	 d d l
 m Z d d  Z d d  Z d d  Z d d   Z d d!  Z d d"  Z d d#  Z d d$  Z d d%  Z d d&  Z d d'  Z d d(  Z d d)  Z d d*  Z d d+  Z d d,  Z d d-  Z d.   Z d d/  Z d d0  Z  d d1  Z! d d2  Z" d d3  Z# d d4  Z$ d S(5   sI   
Various small and named graphs, together with some compact generators.

s=   Aric Hagberg (hagberg@lanl.gov)
Pieter Swart (swart@lanl.gov)t   make_small_grapht	   LCF_grapht
   bull_grapht   chvatal_grapht   cubical_grapht   desargues_grapht   diamond_grapht   dodecahedral_grapht   frucht_grapht   heawood_grapht   house_grapht   house_x_grapht   icosahedral_grapht   krackhardt_kite_grapht   moebius_kantor_grapht   octahedral_grapht   pappus_grapht   petersen_grapht   sedgewick_maze_grapht   tetrahedral_grapht   truncated_cube_grapht   truncated_tetrahedron_grapht   tutte_graphi˙˙˙˙N(   t   empty_grapht   cycle_grapht
   path_grapht   complete_graph(   t   NetworkXErrorc         C   s4   | d k	 r' | j   r' t d   n  t |  |  S(   sd   
    Return a small undirected graph described by graph_description.

    See make_small_graph.
    s   Directed Graph not supportedN(   t   Nonet   is_directedR   R    (   t   graph_descriptiont   create_using(    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyt   make_small_undirected_graph-   s    c         C   sX  |  d } |  d } |  d } t  | |  } | j   } | d k rŽ |  d } t |  | k rp t d   n  | j g  | D]' } | | D] }	 |	 d | f ^ q q}  n | d k rK|  d }
 x |
 D]y } | d d } | d d } | d k  s%| | d k s%| d k  s%| | d k r4t d   qË | j | |  qË Wn  | | _ | S(   s`  
    Return the small graph described by graph_description.

    graph_description is a list of the form [ltype,name,n,xlist]

    Here ltype is one of "adjacencylist" or "edgelist",
    name is the name of the graph and n the number of nodes.
    This constructs a graph of n nodes with integer labels 0,..,n-1.
    
    If ltype="adjacencylist"  then xlist is an adjacency list
    with exactly n entries, in with the j'th entry (which can be empty)
    specifies the nodes connected to vertex j.
    e.g. the "square" graph C_4 can be obtained by

    >>> G=nx.make_small_graph(["adjacencylist","C_4",4,[[2,4],[1,3],[2,4],[1,3]]])

    or, since we do not need to add edges twice,
    
    >>> G=nx.make_small_graph(["adjacencylist","C_4",4,[[2,4],[3],[4],[]]])
    
    If ltype="edgelist" then xlist is an edge list 
    written as [[v1,w2],[v2,w2],...,[vk,wk]],
    where vj and wj integers in the range 1,..,n
    e.g. the "square" graph C_4 can be obtained by
 
    >>> G=nx.make_small_graph(["edgelist","C_4",4,[[1,2],[3,4],[2,3],[4,1]]])

    Use the create_using argument to choose the graph class/type. 
    i    i   i   t   adjacencylisti   s   invalid graph_descriptiont   edgelist(   R   t   nodest   lenR   t   add_edges_fromt   add_edget   name(   R   R   t   ltypeR'   t   nt   GR#   t   adjlistt   vt   uR"   t   et   v1t   v2(    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR    7   s(    



>
8	c         C   să   | d k	 r' | j   r' t d   n  |  d k r@ t d |  St |  |  } d | _ | j   } | t |  } | d k  r | SxX t |  D]J } | | t |  } | | |  }	 | | | |  }
 | j	 |	 |
  q W| S(   sf  
    Return the cubic graph specified in LCF notation.

    LCF notation (LCF=Lederberg-Coxeter-Fruchte) is a compressed
    notation used in the generation of various cubic Hamiltonian
    graphs of high symmetry. See, for example, dodecahedral_graph,
    desargues_graph, heawood_graph and pappus_graph below.
    
    n (number of nodes)
      The starting graph is the n-cycle with nodes 0,...,n-1.
      (The null graph is returned if n < 0.)

    shift_list = [s1,s2,..,sk], a list of integer shifts mod n,

    repeats
      integer specifying the number of times that shifts in shift_list
      are successively applied to each v_current in the n-cycle
      to generate an edge between v_current and v_current+shift mod n.

    For v1 cycling through the n-cycle a total of k*repeats
    with shift cycling through shiftlist repeats times connect
    v1 with v1+shift mod n
          
    The utility graph K_{3,3}

    >>> G=nx.LCF_graph(6,[3,-3],3)
    
    The Heawood graph

    >>> G=nx.LCF_graph(14,[5,-5],7)

    See http://mathworld.wolfram.com/LCFNotation.html for a description
    and references.
    
    s   Directed Graph not supportedi    R   i   N(
   R   R   R   R   R   R'   R#   R$   t   rangeR&   (   R)   t
   shift_listt   repeatsR   R*   R#   t   n_extra_edgest   it   shiftR/   R0   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   n   s     $	c         C   sR   d d d d d g d d d g d d d g d g d g g g } t  | |   } | S(   s   Return the Bull graph. R!   s
   Bull Graphi   i   i   i   i   (   R    (   R   t   descriptionR*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   Ż   s    6c         C   s   d d d d d d d g d d	 d
 g d d d g d d
 d g d	 d g d d g d d g d d g d g d d g g  g  g g } t  | |   } | S(   s   Return the ChvĂĄtal graph.R!   s   Chvatal Graphi   i   i   i   i
   i   i   i   i   i	   i   (   R    (   R   R7   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   ş   s    3$c         C   s   d d d d d d g d d d g d d d	 g d d d
 g d d
 d g d d d	 g d d
 d g d d d	 g g g } t  | |   } | S(   s,   Return the 3-regular Platonic Cubical graph.R!   s   Platonic Cubical Graphi   i   i   i   i   i   i   i   (   R    (   R   R7   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   Ç   s    09c         C   s.   t  d d d d d g d |   } d | _ | S(   s    Return the Desargues graph.i   i   iű˙˙˙i	   i÷˙˙˙s   Desargues Graph(   R   R'   (   R   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   Ó   s    !	c         C   sO   d d d d d g d d d g d d d g d d g g g } t  | |   } | S(   s   Return the Diamond graph. R!   s   Diamond Graphi   i   i   i   (   R    (   R   R7   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   Ů   s    3c         C   s@   t  d d d d d d d d d d d g
 d |   } d | _ | S(	   s)    Return the Platonic Dodecahedral graph. i   i
   i   i   iü˙˙˙iů˙˙˙i   s   Dodecahedral Graph(   R   R'   (   R   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   ä   s    3	c         C   s   t  d |   } | j d d g d d g d d g d d g d d g d	 d
 g d d
 g d d g d d g d d g d
 d g g  d | _ | S(   s   Return the Frucht Graph.

    The Frucht Graph is the smallest cubical graph whose
    automorphism group consists only of the identity element.

    i   i    i   i   i   i   i	   i   i   i
   i   i   s   Frucht Graph(   R   R%   R'   (   R   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   ę   s
    E+	c         C   s(   t  d d d g d |   } d | _ | S(   s)    Return the Heawood graph, a (3,6) cage. i   i   iű˙˙˙i   s   Heawood Graph(   R   R'   (   R   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR	   ř   s    	c      	   C   sX   d d d d d g d d g d d d g d d d g d d g g g } t  | |   } | S(   s5   Return the House graph (square with triangle on top).R!   s   House Graphi   i   i   i   i   (   R    (   R   R7   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR
   ţ   s    <c      
   C   sd   d d d d d d g d d d g d d d d g d d d d g d d g g g } t  | |   } | S(   s<   Return the House graph with a cross inside the house square.R!   s   House-with-X-inside Graphi   i   i   i   i   (   R    (   R   R7   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   	  s    Hc         C   sŁ   d d d d d d d d g d d d	 d g d
 d	 d d g d d	 d d g d d	 d d g d	 d g g  d d d d g d g d g d g g  g g } t  | |   } | S(   s&   Return the Platonic Icosahedral graph.R!   s   Platonic Icosahedral Graphi   i   i   i   i	   i   i   i   i
   i   i   (   R    (   R   R7   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR     s    ?*c         C   sŻ   d d d d d d d g d d d	 d
 g d d d g d d d d	 d d
 g d d d
 g d d d d
 d g d d d	 d d g d d
 d g d d g d g g
 g } t  | |   } | S(   sC  
    Return the Krackhardt Kite Social Network.
 
    A 10 actor social network introduced by David Krackhardt
    to illustrate: degree, betweenness, centrality, closeness, etc. 
    The traditional labeling is:
    Andre=1, Beverley=2, Carol=3, Diane=4,
    Ed=5, Fernando=6, Garth=7, Heather=8, Ike=9, Jane=10.
    
    R!   s   Krackhardt Kite Social Networki
   i   i   i   i   i   i   i   i   i	   (   R    (   R   R7   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   "  s    KHc         C   s(   t  d d d g d |   } d | _ | S(   s    Return the Moebius-Kantor graph.i   i   iű˙˙˙i   s   Moebius-Kantor Graph(   R   R'   (   R   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   7  s    	c      	   C   s[   d d d d d d d g d d d g d d g d d g d g g  g g } t  | |   } | S(   s%   Return the Platonic Octahedral graph.R!   s   Platonic Octahedral Graphi   i   i   i   i   (   R    (   R   R7   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   =  s    ?c          C   s1   t  d d d d d d d g d  }  d |  _ |  S(   s    Return the Pappus graph.i   i   i   iů˙˙˙iű˙˙˙i   s   Pappus Graph(   R   R'   (   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   H  s    $	c         C   s   d d d d d d g d d d	 g d d
 d g d d d g d
 d d g d d d g d d d g d d d g d
 d d	 g d d	 d g g
 g } t  | |   } | S(   s   Return the Petersen graph.R!   s   Petersen Graphi
   i   i   i   i   i   i   i   i   i	   (   R    (   R   R7   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   N  s    T-c         C   s˝   t  d |   } | j t d   | j d d g d d g d d g g  | j d d g d d g g  | j d d	 g d d g g  | j d	 d g d	 d g d	 d g g  d
 | _ | S(   sČ   
    Return a small maze with a cycle.

    This is the maze used in Sedgewick,3rd Edition, Part 5, Graph
    Algorithms, Chapter 18, e.g. Figure 18.2 and following.
    Nodes are numbered 0,..,7
    i    i   i   i   i   i   i   i   i   s   Sedgewick Maze(   R   t   add_nodes_fromR1   R%   R'   (   R   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   [  s    ((	c         C   s   t  d |   } d | _ | S(   s1    Return the 3-regular Platonic Tetrahedral graph.i   s   Platonic Tetrahedral graph(   R   R'   (   R   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   l  s    	c         C   sŮ   d d d d d d g d d g d	 d g d
 d g d g d d g d d g d d g d g d d g d d g d g d g d d g d g d d g d d g d g d g d g d g d g d g g  g g } t  | |   } | S(   s*   Return the skeleton of the truncated cube.R!   s   Truncated Cube Graphi   i   i   i   i   i   i   i   i	   i   i   i   i   i   i   i
   i   i   i   i   i   i   i   (   R    (   R   R7   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR   r  s    '!c      	   C   s>   t  d |   } | j d d d d d d d g  d | _ | S(   s:   Return the skeleton of the truncated Platonic tetrahedron.i   i    i   i	   i   i   i   i   i   i   i   i   i
   s   Truncated Tetrahedron Graph(   i    i   (   i    i	   (   i   i   (   i   i   (   i   i   (   i   i   (   i   i
   (   R   R%   R'   (   R   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR     s    "	c      1   C   s~  d d d d d d g d d g d	 d
 g d d g d d g d d g d d g d d g d d g d	 d g d g d d g d d g d d g d g d d g d  d! g d d" g d g d# d g d$ d% g d d& g d' g d( d g d) d* g d d+ g d g d, g d d* g d- g d+ d g d* g g  g  d d g d. g d d g d g g  g  d% d! g d/ g d" d g d! g g  g  g. g } t  | |   } | S(0   s   Return the Tutte graph.R!   s   Tutte's Graphi.   i   i   i   i   i   i   i   i   i   i   i"   i   i   i   i   i	   i   i
   i'   i&   i(   i   i   i$   i   i#   i   i   i   i-   i,   i   i   i*   i   i)   i   i   i!   i    i   i   i%   i+   (   R    (   R   R7   R*   (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyR     s    0-'**$-(%   t   __doc__t
   __author__t   __all__t   networkxt   nxt   networkx.generators.classicR   R   R   R   t   networkx.exceptionR   R   R    R    R   R   R   R   R   R   R   R   R	   R
   R   R   R   R   R   R   R   R   R   R   R   R   (    (    (    sm   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/small.pyt   <module>   sf   	"
7A	