ó
|£*^c           @   s™  d  Z  d d l Z d d l m Z d d l m Z d Z 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 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 d% „ Z e d d& „ Z e d' „ Z d( „  Z d d) „ Z d d* „ Z d d+ „ Z d d, „ Z d d- „ Z d d. „ Z  d d/ „ Z! d0 „  Z" d S(1   s5  
Generators for some classic graphs.

The typical graph generator is called as follows:

>>> G=nx.complete_graph(100)

returning the complete graph on n nodes labeled 0,..,99
as a simple graph. Except for empty_graph, all the generators
in this module return a Graph class (i.e. a simple, undirected graph).

iÿÿÿÿN(   t   complete_bipartite_graph(   t
   accumulates=   Aric Hagberg (hagberg@lanl.gov)
Pieter Swart (swart@lanl.gov)t   balanced_treet   barbell_grapht   complete_grapht   complete_multipartite_grapht   circular_ladder_grapht   circulant_grapht   cycle_grapht    dorogovtsev_goltsev_mendes_grapht   empty_grapht   full_rary_treet
   grid_grapht   grid_2d_grapht   hypercube_grapht   ladder_grapht   lollipop_grapht
   null_grapht
   path_grapht
   star_grapht   trivial_grapht   wheel_graph(   t   is_list_of_intst   flattenc         c   s•   t  t |  ƒ ƒ } t | ƒ g } xm | r� | j d ƒ } xQ t | ƒ D]C } y( t | ƒ } | j | ƒ | | f VWqF t k
 rˆ PqF XqF Wq$ Wd  S(   Ni    (   t   itert   ranget   nextt   popt   appendt   StopIteration(   t   nt   rt   nodest   parentst   sourcet   it   target(    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyt   _tree_edges6   s    	c         C   s,   t  j | | ƒ } | j t | |  ƒ ƒ | S(   sA  Creates a full r-ary tree of n vertices.

    Sometimes called a k-ary, n-ary, or m-ary tree.  "... all non-leaf
    vertices have exactly r children and all levels are full except
    for some rightmost position of the bottom level (if a leaf at the
    bottom level is missing, then so are all of the leaves to its
    right." [1]_

    Parameters
    ----------
    r : int
        branching factor of the tree
    n : int
        Number of nodes in the tree
    create_using : NetworkX graph type, optional
        Use specified type to construct graph (default = networkx.Graph)

    Returns
    -------
    G : networkx Graph
        An r-ary tree with n nodes

    References
    ----------
    .. [1] An introduction to data structures and algorithms,
           James Andrew Storer,  Birkhauser Boston 2001, (page 225).
    (   t   nxR
   t   add_edges_fromR%   (   R   R   t   create_usingt   G(    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR   E   s    c         C   st   |  d k r d } n  t  d |  | d d |  ƒ } t j | | ƒ } | j t | |  ƒ ƒ | St j |  | | ƒ S(   sœ  Return the perfectly balanced r-tree of height h.

    Parameters
    ----------
    r : int
        Branching factor of the tree
    h : int
        Height of the tree
    create_using : NetworkX graph type, optional
        Use specified type to construct graph (default = networkx.Graph)

    Returns
    -------
    G : networkx Graph
        A tree with n nodes

    Notes
    -----
    This is the rooted tree where all leaves are at distance h from
    the root. The root has degree r and all other internal nodes have
    degree r+1.

    Node labels are the integers 0 (the root) up to  number_of_nodes - 1.

    Also refered to as a complete r-ary tree.
    i   i   (   t   intR&   R
   R'   R%   R   (   R   t   hR(   R   R)   (    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR   e   s    	 c            s{  | d	 k	 r* | j ƒ  r* t j d ƒ ‚ n  ˆ  d k  rH t j d ƒ ‚ n  ˆ d k  rf t j d ƒ ‚ n  t ˆ  | ƒ } d ˆ  ˆ f | _ | j g  t ˆ  ˆ  ˆ d ƒ D] } | ^ q¦ ƒ ˆ d k r| j g  t ˆ  ˆ  ˆ d ƒ D] } | | d f ^ qã ƒ n  | j ‡  ‡ f d †  t ˆ  ˆ d ˆ  ˆ ƒ Dƒ ƒ | j	 ˆ  d ˆ  ƒ ˆ d k rw| j	 ˆ  ˆ d ˆ  ˆ ƒ n  | S(
   sy  Return the Barbell Graph: two complete graphs connected by a path.

    For m1 > 1 and m2 >= 0.

    Two identical complete graphs K_{m1} form the left and right bells,
    and are connected by a path P_{m2}.

    The 2*m1+m2  nodes are numbered
        0,...,m1-1 for the left barbell,
        m1,...,m1+m2-1 for the path,
        and m1+m2,...,2*m1+m2-1 for the right barbell.

    The 3 subgraphs are joined via the edges (m1-1,m1) and (m1+m2-1,m1+m2).
    If m2=0, this is merely two complete graphs joined together.

    This graph is an extremal example in David Aldous
    and Jim Fill's etext on Random Walks on Graphs.

    s   Directed Graph not supportedi   s+   Invalid graph description, m1 should be >=2i    s+   Invalid graph description, m2 should be >=0s   barbell_graph(%d,%d)i   c         3   s=   |  ]3 } t  | d  d ˆ  ˆ ƒ D] } | | f Vq" q d S(   i   i   N(   R   (   t   .0t   ut   v(   t   m1t   m2(    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pys	   <genexpr>±   s    N(
   t   Nonet   is_directedR&   t   NetworkXErrorR   t   namet   add_nodes_fromR   R'   t   add_edge(   R/   R0   R(   R)   R.   (    (   R/   R0   so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR   ‹   s$    1>5c         C   s{   t  |  | ƒ } d |  | _ |  d k rw | j ƒ  rO t j t |  ƒ d ƒ } n t j t |  ƒ d ƒ } | j | ƒ n  | S(   s]    Return the complete graph K_n with n nodes.

    Node labels are the integers 0 to n-1.
    s   complete_graph(%d)i   i   (   R
   R4   R2   t	   itertoolst   permutationsR   t   combinationsR'   (   R   R(   R)   t   edges(    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR   ¸   s    c         C   sL   t  |  | ƒ } d |  | _ | j d |  d ƒ | j |  d |  d ƒ | S(   sÝ   Return the circular ladder graph CL_n of length n.

    CL_n consists of two concentric n-cycles in which
    each of the n pairs of concentric nodes are joined by an edge.

    Node labels are the integers 0 to n-1

    s   circular_ladder_graph(%d)i    i   i   (   R   R4   R6   (   R   R(   R)   (    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR   È   s
    	c         C   s—   t  |  | ƒ } d } | |  d j d „  | Dƒ ƒ f | _ xU t |  ƒ D]G } x> | D]6 } | j | | | |  ƒ | j | | | |  ƒ qU WqH W| S(   s   Generates the circulant graph Ci_n(x_1, x_2, ..., x_m) with n vertices.

    Returns
    -------
    The graph Ci_n(x_1, ..., x_m) consisting of n vertices 0, ..., n-1 such
    that the vertex with label i is connected to the vertices labelled (i + x)
    and (i - x), for all x in x_1 up to x_m, with the indices taken modulo n.

    Parameters
    ----------
    n : integer
        The number of vertices the generated graph is to contain.
    offsets : list of integers
        A list of vertex offsets, x_1 up to x_m, as described above.
    create_using : NetworkX graph type, optional
        Use specified type to construct graph (default = networkx.Graph)

    Examples
    --------
    Many well-known graph families are subfamilies of the circulant graphs; for
    example, to generate the cycle graph on n points, we connect every vertex to
    every other at offset plus or minus one. For n = 10,

    >>> import networkx
    >>> G = networkx.generators.classic.circulant_graph(10, [1])
    >>> edges = [
    ...     (0, 9), (0, 1), (1, 2), (2, 3), (3, 4),
    ...     (4, 5), (5, 6), (6, 7), (7, 8), (8, 9)]
    ...
    >>> sorted(edges) == sorted(G.edges())
    True

    Similarly, we can generate the complete graph on 5 points with the set of
    offsets [1, 2]:

    >>> G = networkx.generators.classic.circulant_graph(5, [1, 2])
    >>> edges = [
    ...     (0, 1), (0, 2), (0, 3), (0, 4), (1, 2),
    ...     (1, 3), (1, 4), (2, 3), (2, 4), (3, 4)]
    ...
    >>> sorted(edges) == sorted(G.edges())
    True

    s   circulant_graph(%d, [%s])s   , c         s   s   |  ] } t  | ƒ Vq d  S(   N(   t   str(   R,   t   j(    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pys	   <genexpr>  s    (   R
   t   joinR4   R   R6   (   R   t   offsetsR(   R)   t   templateR#   R<   (    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR   Ø   s    -& c         C   sC   t  |  | ƒ } d |  | _ |  d k r? | j |  d d ƒ n  | S(   sÖ   Return the cycle graph C_n over n nodes.

    C_n is the n-path with two end-nodes connected.

    Node labels are the integers 0 to n-1
    If create_using is a DiGraph, the direction is in increasing order.

    s   cycle_graph(%d)i   i    (   R   R4   R6   (   R   R(   R)   (    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR     s
    	 c         C   s  | d k	 rK | j ƒ  r* t j d ƒ ‚ n  | j ƒ  rK t j d ƒ ‚ qK n  t d | ƒ } d | _ | j d d ƒ |  d k rƒ | Sd } x‡ t d |  d ƒ D]r } | j	 ƒ  } t
 | ƒ } xQ t d | ƒ D]@ } | j | | | d ƒ | j | | | d ƒ | d 7} qË Wq� W| S(   s¬   Return the hierarchically constructed Dorogovtsev-Goltsev-Mendes graph.

    n is the generation.
    See: arXiv:/cond-mat/0112143 by Dorogovtsev, Goltsev and Mendes.

    s   Directed Graph not supporteds   Multigraph not supportedi    s    Dorogovtsev-Goltsev-Mendes Graphi   i   N(   R1   R2   R&   R3   t   is_multigraphR
   R4   R6   R   R:   t   len(   R   R(   R)   t   new_nodeR#   t   last_generation_edgest"   number_of_edges_in_last_generationR<   (    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR	     s&    	i    c         C   sO   | d k r t j ƒ  } n | } | j ƒ  | j t |  ƒ ƒ d |  | _ | S(   só  Return the empty graph with n nodes and zero edges.

    Node labels are the integers 0 to n-1

    For example:
    >>> G=nx.empty_graph(10)
    >>> G.number_of_nodes()
    10
    >>> G.number_of_edges()
    0

    The variable create_using should point to a "graph"-like object that
    will be cleaned (nodes and edges will be removed) and refitted as
    an empty "graph" with n nodes with integer labels. This capability
    is useful for specifying the class-nature of the resulting empty
    "graph" (i.e. Graph, DiGraph, MyWeirdGraphClass, etc.).

    The variable create_using has two main uses:
    Firstly, the variable create_using can be used to create an
    empty digraph, network,etc.  For example,

    >>> n=10
    >>> G=nx.empty_graph(n,create_using=nx.DiGraph())

    will create an empty digraph on n nodes.

    Secondly, one can pass an existing graph (digraph, pseudograph,
    etc.) via create_using. For example, if G is an existing graph
    (resp. digraph, pseudograph, etc.), then empty_graph(n,create_using=G)
    will empty G (i.e. delete all nodes and edges using G.clear() in
    base) and then add n nodes and zero edges, and return the modified
    graph (resp. digraph, pseudograph, etc.).

    See also create_empty_copy(G).

    s   empty_graph(%d)N(   R1   R&   t   Grapht   clearR5   R   R4   (   R   R(   R)   (    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR
   7  s    %
c            s¦  t  d | ƒ } d | _ t ˆ ƒ } t ˆ ƒ ‰  | j ‡  f d †  | Dƒ ƒ | j ‡  f d †  | Dƒ ƒ | j ‡  f d †  | Dƒ ƒ | j ƒ  rÖ | j ‡  ‡ f d †  | Dƒ ƒ | j ‡  ‡ f d †  | Dƒ ƒ n  | r¢ˆ d k r4| j ‡ f d	 †  | Dƒ ƒ | j ƒ  r4| j ‡ f d
 †  | Dƒ ƒ q4n  ˆ d k rŒ| j ‡ f d †  ˆ  Dƒ ƒ | j ƒ  rŒ| j ‡ f d †  ˆ  Dƒ ƒ qŒn  d ˆ ˆ f | _ n  | S(   sË    Return the 2d grid graph of mxn nodes,
        each connected to its nearest neighbors.
        Optional argument periodic=True will connect
        boundary nodes via periodic boundary conditions.
    i    R   c         3   s(   |  ] } ˆ  D] } | | f Vq q d  S(   N(    (   R,   R#   R<   (   t   columns(    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pys	   <genexpr>q  s    c         3   sD   |  ]: } ˆ  D]- } | d  k r | | f | d | f f Vq q d S(   i    i   N(    (   R,   R#   R<   (   RG   (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pys	   <genexpr>r  s    c         3   sD   |  ]: } ˆ  D]- } | d  k r | | f | | d f f Vq q d S(   i    i   N(    (   R,   R#   R<   (   RG   (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pys	   <genexpr>s  s    c         3   sH   |  ]> } ˆ  D]1 } | ˆ d  k  r | | f | d  | f f Vq q d S(   i   N(    (   R,   R#   R<   (   RG   t   m(    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pys	   <genexpr>u  s    c         3   sH   |  ]> } ˆ  D]1 } | ˆ d  k  r | | f | | d  f f Vq q d S(   i   N(    (   R,   R#   R<   (   RG   R   (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pys	   <genexpr>v  s    i   c         3   s+   |  ]! } | d  f | ˆ  d f f Vq d S(   i    i   N(    (   R,   R#   (   R   (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pys	   <genexpr>y  s    c         3   s+   |  ]! } | ˆ  d  f | d f f Vq d S(   i   i    N(    (   R,   R#   (   R   (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pys	   <genexpr>{  s    c         3   s+   |  ]! } d  | f ˆ  d | f f Vq d S(   i    i   N(    (   R,   R<   (   RH   (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pys	   <genexpr>}  s    c         3   s+   |  ]! } ˆ  d  | f d | f f Vq d S(   i   i    N(    (   R,   R<   (   RH   (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pys	   <genexpr>  s    s   periodic_grid_2d_graph(%d,%d)(   R
   R4   R   R5   R'   R2   (   RH   R   t   periodicR(   R)   t   rows(    (   RG   RH   R   so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR   g  s*    	 ###c   	      C   s   d |  } |  g  k r3 t  d ƒ } d |  | _ | St |  ƒ sQ t j d ƒ ‚ n  t |  ƒ d k ru t j d ƒ ‚ n  | r„ t } n t } t |  ƒ }  |  j	 ƒ  } | | ƒ } xL t
 |  ƒ d k rü |  j	 ƒ  } | j ƒ  } | | ƒ } t j | | ƒ } q± Wt j | t ƒ } d | | _ | S(   s.   Return the n-dimensional grid graph.

    The dimension is the length of the list 'dim' and the
    size in each dimension is the value of the list element.

    E.g. G=grid_graph(dim=[2,3]) produces a 2x3 grid graph.

    If periodic=True then join grid edges with periodic boundary conditions.

    s   %si    s   grid_graph(%s)s   dim is not a list of integerss/   dim is not a list of strictly positive integers(   R
   R4   R   R&   R3   t   minR   R   t   listR   RA   t   copyt   cartesian_productt   relabel_nodesR   (	   t   dimRI   t   dlabelR)   t   funct   current_dimt   Goldt   Gnewt   H(    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR   „  s0    
	c         C   s*   |  d g } t  | ƒ } d |  | _ | S(   sZ   Return the n-dimensional hypercube.

    Node labels are the integers 0 to 2**n - 1.

    i   s   hypercube_graph_(%d)(   R   R4   (   R   RP   R)   (    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR   ¯  s    c         C   sí   | d k	 r* | j ƒ  r* t j d ƒ ‚ n  t d |  | ƒ } d |  | _ | j g  t |  d ƒ D] } | | d f ^ qa ƒ | j g  t |  d |  d ƒ D] } | | d f ^ qœ ƒ | j g  t |  ƒ D] } | | |  f ^ qÌ ƒ | S(   s«   Return the Ladder graph of length n.

    This is two rows of n nodes, with
    each pair connected by a single edge.

    Node labels are the integers 0 to 2*n - 1.

    s   Directed Graph not supportedi   s   ladder_graph_(%d)i   N(   R1   R2   R&   R3   R
   R4   R'   R   (   R   R(   R)   R.   (    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR   º  s    	4;0c         C   s&  | d k	 r* | j ƒ  r* t j d ƒ ‚ n  |  d k  rH t j d ƒ ‚ n  | d k  rf t j d ƒ ‚ n  t |  | ƒ } | j g  t |  |  | ƒ D] } | ^ q� ƒ | d k rì | j g  t |  |  | d ƒ D] } | | d f ^ qÌ ƒ n  |  d k r| j |  d |  ƒ n  d |  | f | _	 | S(	   s9  Return the Lollipop Graph; `K_m` connected to `P_n`.

    This is the Barbell Graph without the right barbell.

    For m>1 and n>=0, the complete graph K_m is connected to the
    path P_n.  The resulting m+n nodes are labelled 0,...,m-1 for the
    complete graph and m,...,m+n-1 for the path. The 2 subgraphs
    are joined via the edge (m-1,m).  If n=0, this is merely a complete
    graph.

    Node labels are the integers 0 to number_of_nodes - 1.

    (This graph is an extremal example in David Aldous and Jim
    Fill's etext on Random Walks on Graphs.)

    s   Directed Graph not supportedi   s*   Invalid graph description, m should be >=2i    s*   Invalid graph description, n should be >=0i   s   lollipop_graph(%d,%d)N(
   R1   R2   R&   R3   R   R5   R   R'   R6   R4   (   RH   R   R(   R)   R.   (    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR   Ì  s     -> c         C   s   t  d |  ƒ } d | _ | S(   se   Return the Null graph with no nodes or edges.

    See empty_graph for the use of create_using.

    i    s   null_graph()(   R
   R4   (   R(   R)   (    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR   ñ  s    	c         C   sT   t  |  | ƒ } d |  | _ | j g  t |  d ƒ D] } | | d f ^ q3 ƒ | S(   sÏ   Return the Path graph P_n of n nodes linearly connected by n-1 edges.

    Node labels are the integers 0 to n - 1.
    If create_using is a DiGraph then the edges are directed in
    increasing order.

    s   path_graph(%d)i   (   R
   R4   R'   R   (   R   R(   R)   R.   (    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR   û  s    4c         C   s#   t  d |  | ƒ } d |  | _ | S(   s‚    Return the Star graph with n+1 nodes: one center node, connected to n outer nodes.

   Node labels are the integers 0 to n.

    i   s   star_graph(%d)(   R    R4   (   R   R(   R)   (    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR     s    c         C   s   t  d |  ƒ } d | _ | S(   sR    Return the Trivial graph with one node (with integer label 0) and no edges.

    i   s   trivial_graph()(   R
   R4   (   R(   R)   (    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR     s    	c         C   s�   |  d k r t  j |  d | ƒSt |  d | ƒ } d |  | _ | j g  t d |  d ƒ D] } | | d f ^ qY ƒ |  d k r™ | j d |  d ƒ n  | S(   s“    Return the wheel graph: a single hub node connected to each node of the (n-1)-node cycle graph.

   Node labels are the integers 0 to n - 1.

    i    R(   i   s   wheel_graph(%d)i   (   R&   R
   R   R4   R'   R   R6   (   R   R(   R)   R.   (    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR     s    7c    
      G   sç   t  j t |  ƒ ƒ } t d g t t |  ƒ ƒ t |  ƒ ƒ } g  | D] \ } } t | | ƒ ^ qD } x- t | ƒ D] \ } } | j | d | ƒqr Wx9 t	 j
 | d ƒ D]% \ } }	 | j t	 j | |	 ƒ ƒ q¨ Wd j |  ƒ | _ | S(   s  Returns the complete multipartite graph with the specified block sizes.

    Parameters
    ----------

    block_sizes : tuple of integers

       The number of vertices in each block of the multipartite graph. The
       length of this tuple is the number of blocks.

    Returns
    -------

    G : NetworkX Graph

       Returns the complete multipartite graph with the specified block sizes.

       For each node, the node attribute ``'block'`` is an integer indicating
       which block contains the node.

    Examples
    --------

    Creating a complete tripartite graph, with blocks of one, two, and three
    vertices, respectively.

        >>> import networkx as nx
        >>> G = nx.complete_multipartite_graph(1, 2, 3)
        >>> [G.node[u]['block'] for u in G]
        [0, 1, 1, 2, 2, 2]
        >>> G.edges(0)
        [(0, 1), (0, 2), (0, 3), (0, 4), (0, 5)]
        >>> G.edges(2)
        [(2, 0), (2, 3), (2, 4), (2, 5)]
        >>> G.edges(4)
        [(4, 0), (4, 1), (4, 2)]

    Notes
    -----

    This function generalizes several other graph generator functions.

    - If no block sizes are given, this returns the null graph.
    - If a single block size ``n`` is given, this returns the empty graph on
      ``n`` nodes.
    - If two block sizes ``m`` and ``n`` are given, this returns the complete
      bipartite graph on ``m + n`` nodes.
    - If block sizes ``1`` and ``n`` are given, this returns the star graph on
      ``n + 1`` nodes.

    See also
    --------

    complete_bipartite_graph

    i    t   blocki   s   complete_multiparite_graph{0}(   R&   R
   t   sumt   zipRL   R   R   t	   enumerateR5   R7   R9   R'   t   productt   formatR4   (
   t   block_sizesR)   t   extentst   startt   endt   blocksR#   RW   t   block1t   block2(    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyR   *  s    9(((#   t   __doc__R7   t(   networkx.algorithms.bipartite.generatorsR    t   networkx.utilsR   t
   __author__t   __all__t   networkxR&   R   R   R%   R1   R   R   R   R   R   R   R   R	   R
   t   FalseR   R   R   R   R   R   R   R   R   R   R   (    (    (    so   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/classic.pyt   <module>   s^   		 &-60+	%

