ó
|£*^c           @   s  d  Z  d d l Z d d l m Z m Z d d l Z d d l m Z d d l Z d d l	 Z
 d d l m Z d j d d d	 d
 g ƒ Z d d d d d d d g Z d d d „ Z d d d „ Z d e d „ Z d d „ Z d d „ Z d d „ Z d d d „ Z d e f d „  ƒ  YZ d S(   sJ   Generate graphs with a given degree sequence or expected degree sequence.
iÿÿÿÿN(   t   combinationst   permutations(   t
   itemgetter(   t   random_weighted_samples   
s%   Aric Hagberg <aric.hagberg@gmail.com>s   Pieter Swart <swart@lanl.gov>sN   Dan Schult <dschult@colgate.edu>Joel Miller <joel.c.miller.research@gmail.com>sI   Nathan Lemons <nlemons@gmail.com>Brian Cloteaux <brian.cloteaux@nist.gov>t   configuration_modelt   directed_configuration_modelt   expected_degree_grapht   havel_hakimi_grapht   directed_havel_hakimi_grapht   degree_sequence_treet   random_degree_sequence_graphc   
      C   sa  t  |  ƒ d d k s( t j d ƒ ‚ n  | d k rC t j ƒ  } n | j ƒ  ra t j d ƒ ‚ n  | d k	 r} t j | ƒ n  t |  ƒ } t j	 | | ƒ } | d k s¹ t
 |  ƒ d k r½ | Sg  } x6 | D]. } x% t |  | ƒ D] } | j | ƒ qá WqÊ Wt j | ƒ x2 | r=| j ƒ  } | j ƒ  }	 | j | |	 ƒ qWd | j ƒ  | j ƒ  f | _ | S(   sø	  Return a random graph with the given degree sequence.

    The configuration model generates a random pseudograph (graph with
    parallel edges and self loops) by randomly assigning edges to
    match the given degree sequence.

    Parameters
    ----------
    deg_sequence :  list of integers
        Each list entry corresponds to the degree of a node.
    create_using : graph, optional (default MultiGraph)
       Return graph of this type. The instance will be cleared.
    seed : hashable object, optional
        Seed for random number generator.

    Returns
    -------
    G : MultiGraph
        A graph with the specified degree sequence.
        Nodes are labeled starting at 0 with an index
        corresponding to the position in deg_sequence.

    Raises
    ------
    NetworkXError
        If the degree sequence does not have an even sum.

    See Also
    --------
    is_valid_degree_sequence

    Notes
    -----
    As described by Newman [1]_.

    A non-graphical degree sequence (not realizable by some simple
    graph) is allowed since this function returns graphs with self
    loops and parallel edges.  An exception is raised if the degree
    sequence does not have an even sum.

    This configuration model construction process can lead to
    duplicate edges and loops.  You can remove the self-loops and
    parallel edges (see below) which will likely result in a graph
    that doesn't have the exact degree sequence specified.  
    
    The density of self-loops and parallel edges tends to decrease 
    as the number of nodes increases. However, typically the number 
    of self-loops will approach a Poisson distribution with a nonzero 
    mean, and similarly for the number of parallel edges.   Consider a 
    node with k stubs. The probability of being joined to another stub of 
    the same node is basically (k-1)/N where k is the degree and N is 
    the number of nodes. So the probability of a self-loop  scales like c/N 
    for some constant c.  As N grows, this means we expect c self-loops. 
    Similarly for parallel edges.

    References
    ----------
    .. [1] M.E.J. Newman, "The structure and function of complex networks",
       SIAM REVIEW 45-2, pp 167-256, 2003.

    Examples
    --------
    >>> from networkx.utils import powerlaw_sequence
    >>> z=nx.utils.create_degree_sequence(100,powerlaw_sequence)
    >>> G=nx.configuration_model(z)

    To remove parallel edges:

    >>> G=nx.Graph(G)

    To remove self loops:

    >>> G.remove_edges_from(G.selfloop_edges())
    i   i    s   Invalid degree sequences   Directed Graph not supporteds%   configuration_model %d nodes %d edgesN(   t   sumt   nxt   NetworkXErrort   Nonet
   MultiGrapht   is_directedt   randomt   seedt   lent   empty_grapht   maxt   ranget   appendt   shufflet   popt   add_edget   ordert   sizet   name(
   t   deg_sequencet   create_usingR   t   Nt   Gt   stublistt   nt   it   n1t   n2(    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyR   "   s.    K	c         C   sî  t  |  ƒ t  | ƒ k s* t j d ƒ ‚ n  | d k rE t j ƒ  } n  | d k	 ra t j | ƒ n  t |  ƒ } t | ƒ } | | k r  | j | | d g ƒ n |  j | | d g ƒ t |  ƒ } t j	 | | ƒ } | d k sô t
 |  ƒ d k rø | Sg  } x6 | D]. }	 x% t |  |	 ƒ D] }
 | j |	 ƒ qWqWg  } x6 | D]. }	 x% t | |	 ƒ D] }
 | j |	 ƒ q[WqDWt j | ƒ t j | ƒ x8 | rÊ| rÊ| j ƒ  } | j ƒ  } | j | | ƒ q“Wd | j ƒ  | j ƒ  f | _ | S(   s	  Return a directed_random graph with the given degree sequences.

    The configuration model generates a random directed pseudograph
    (graph with parallel edges and self loops) by randomly assigning
    edges to match the given degree sequences.

    Parameters
    ----------
    in_degree_sequence :  list of integers
       Each list entry corresponds to the in-degree of a node.
    out_degree_sequence :  list of integers
       Each list entry corresponds to the out-degree of a node.
    create_using : graph, optional (default MultiDiGraph)
       Return graph of this type. The instance will be cleared.
    seed : hashable object, optional
        Seed for random number generator.

    Returns
    -------
    G : MultiDiGraph
        A graph with the specified degree sequences.
        Nodes are labeled starting at 0 with an index
        corresponding to the position in deg_sequence.

    Raises
    ------
    NetworkXError
        If the degree sequences do not have the same sum.

    See Also
    --------
    configuration_model

    Notes
    -----
    Algorithm as described by Newman [1]_.

    A non-graphical degree sequence (not realizable by some simple
    graph) is allowed since this function returns graphs with self
    loops and parallel edges.  An exception is raised if the degree
    sequences does not have the same sum.

    This configuration model construction process can lead to
    duplicate edges and loops.  You can remove the self-loops and
    parallel edges (see below) which will likely result in a graph
    that doesn't have the exact degree sequence specified.  This
    "finite-size effect" decreases as the size of the graph increases.

    References
    ----------
    .. [1] Newman, M. E. J. and Strogatz, S. H. and Watts, D. J.
       Random graphs with arbitrary degree distributions and their applications
       Phys. Rev. E, 64, 026118 (2001)

    Examples
    --------
    >>> D=nx.DiGraph([(0,1),(1,2),(2,3)]) # directed path graph
    >>> din=list(D.in_degree().values())
    >>> dout=list(D.out_degree().values())
    >>> din.append(1)
    >>> dout[0]=2
    >>> D=nx.directed_configuration_model(din,dout)

    To remove parallel edges:

    >>> D=nx.DiGraph(D)

    To remove self loops:

    >>> D.remove_edges_from(D.selfloop_edges())
    s9   Invalid degree sequences. Sequences must have equal sums.i    s.   directed configuration_model %d nodes %d edgesN(   R   R   R   R   t   MultiDiGraphR   R   R   t   extendR   R   R   R   R   R   R   R   R   R   (   t   in_degree_sequencet   out_degree_sequenceR   R   t   nint   noutR    R!   t   in_stublistR#   R$   t   out_stublistt   sourcet   target(    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyR   •   s>    Jc         C   s,  t  |  ƒ } t j | ƒ } | d k s9 t |  ƒ d k r= | S| d k	 rY t j | ƒ n  d t t |  ƒ ƒ } t	 t
 |  ƒ d t d ƒ d t ƒ} t d „  t
 | ƒ Dƒ ƒ } g  | D] \ } }	 |	 ^ q¶ }
 | } | sç | d 8} n  x>t | ƒ D]0} | }	 | s|	 d 7}	 n  |
 | | } |
 |	 | } | d k rDd } n  xÝ |	 | k  r#| d k r#| d k r­t j ƒ  } |	 t t j t j | ƒ t j d | ƒ ƒ ƒ 7}	 n  |	 | k  rG|
 |	 | } | d k rÜd } n  t j ƒ  | | k  r| j | | | |	 ƒ n  |	 d 7}	 | } qGqGWqô W| S(   sa  Return a random graph with given expected degrees.

    Given a sequence of expected degrees `W=(w_0,w_1,\ldots,w_{n-1}`)
    of length `n` this algorithm assigns an edge between node `u` and
    node `v` with probability

    .. math::

       p_{uv} = \frac{w_u w_v}{\sum_k w_k} .

    Parameters
    ----------
    w : list
        The list of expected degrees.
    selfloops: bool (default=True)
        Set to False to remove the possibility of self-loop edges.
    seed : hashable object, optional
        The seed for the random number generator.

    Returns
    -------
    Graph

    Examples
    --------
    >>> z=[10 for i in range(100)]
    >>> G=nx.expected_degree_graph(z)

    Notes
    -----
    The nodes have integer labels corresponding to index of expected degrees
    input sequence.

    The complexity of this algorithm is `\mathcal{O}(n+m)` where `n` is the
    number of nodes and `m` is the expected number of edges.

    The model in [1]_ includes the possibility of self-loop edges.
    Set selfloops=False to produce a graph without self loops.

    For finite graphs this model doesn't produce exactly the given
    expected degree sequence.  Instead the expected degrees are as
    follows.

    For the case without self loops (selfloops=False),

    .. math::

       E[deg(u)] = \sum_{v \ne u} p_{uv}
                = w_u \left( 1 - \frac{w_u}{\sum_k w_k} \right) .


    NetworkX uses the standard convention that a self-loop edge counts 2
    in the degree of a node, so with self loops (selfloops=True),

    .. math::

       E[deg(u)] =  \sum_{v \ne u} p_{uv}  + 2 p_{uu}
                = w_u \left( 1 + \frac{w_u}{\sum_k w_k} \right) .

    References
    ----------
    .. [1] Fan Chung and L. Lu, Connected components in random graphs with
       given expected degree sequences, Ann. Combinatorics, 6,
       pp. 125-145, 2002.
    .. [2] Joel Miller and Aric Hagberg,
       Efficient generation of networks with given expected degrees,
       in Algorithms and Models for the Web-Graph (WAW 2011),
       Alan Frieze, Paul Horn, and PaweÅ‚ PraÅ‚at (Eds), LNCS 6732,
       pp. 115-126, 2011.
    i    i   t   keyt   reversec         s   s%   |  ] \ } } | | d  f Vq d S(   i    N(    (   t   .0t   ct   uv(    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pys	   <genexpr>f  s    N(   R   R   R   R   R   R   R   t   floatR   t   sortedt	   enumerateR   t   Truet   dictR   t   intt   matht   floort   logR   (   t   wR   t	   selfloopsR#   R!   t   rhoR   t   mappingt   ut   vt   seqt   lastt   factort   pt   rt   q(    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyR     sD    G$	6	
c         C   s˜  t  j |  ƒ s! t  j d ƒ ‚ n  | d k	 rN | j ƒ  rN t  j d ƒ ‚ qN n  t |  ƒ } t  j | | ƒ } g  } x! t | ƒ D] } | j g  ƒ q Wd \ } } } xS |  D]K }	 |	 d k r¬ | |	 j | ƒ t	 | |	 ƒ | |	 | d } } } q¬ q¬ W| d k r| Sd	 g | d }
 xV| d k rtx$ t | | ƒ d k rQ| d 8} q.W| | d k rtt  j d ƒ ‚ n  | | j
 ƒ  } | d 8} d } | } x’ t | ƒ D]„ } x$ t | | ƒ d k rÓ| d 8} q°W| | j
 ƒ  } | j | | ƒ | d 8} | d k r§| d | f |
 | <| d 7} q§q§Wx? t | ƒ D]1 } |
 | \ } } | | j | ƒ | d 7} q<WqWd | j ƒ  | j ƒ  f | _ | S(
   sŒ  Return a simple graph with given degree sequence constructed
    using the Havel-Hakimi algorithm.

    Parameters
    ----------
    deg_sequence: list of integers
        Each integer corresponds to the degree of a node (need not be sorted).
    create_using : graph, optional (default Graph)
        Return graph of this type. The instance will be cleared.
        Directed graphs are not allowed.

    Raises
    ------
    NetworkXException
        For a non-graphical degree sequence (i.e. one
        not realizable by some simple graph).

    Notes
    -----
    The Havel-Hakimi algorithm constructs a simple graph by
    successively connecting the node of highest degree to other nodes
    of highest degree, resorting remaining nodes by degree, and
    repeating the process. The resulting graph has a high
    degree-associativity.  Nodes are labeled 1,.., len(deg_sequence),
    corresponding to their position in deg_sequence.

    The basic algorithm is from Hakimi [1]_ and was generalized by
    Kleitman and Wang [2]_.

    References
    ----------
    .. [1] Hakimi S., On Realizability of a Set of Integers as 
       Degrees of the Vertices of a Linear Graph. I,
       Journal of SIAM, 10(3), pp. 496-506 (1962)
    .. [2] Kleitman D.J. and Wang D.L.
       Algorithms for Constructing Graphs and Digraphs with Given Valences
       and Factors  Discrete Mathematics, 6(1), pp. 79-88 (1973) 
    s   Invalid degree sequences!   Directed graphs are not supportedi    i   s   Non-graphical integer sequences$   havel_hakimi_graph %d nodes %d edgesN(   i    i    i    (   i    i    (   R   t   is_valid_degree_sequenceR   R   R   R   R   R   R   R   R   R   R   R   R   (   R   R   RH   R!   t   num_degsR$   t   dmaxt   dsumR#   t   dt   modstubsR/   t   mslent   kR0   t   stubvalt
   stubtarget(    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyR   �  sT    ',

c         C   sê  t  j j |  ƒ s t ‚ t  j j | ƒ s0 t ‚ | d	 k rK t  j ƒ  } n  d d t |  ƒ t | ƒ f \ } } } } t | | ƒ } t  j | | ƒ } | d k r¦ | Sd }	 g  g  }
 } xô t	 | ƒ D]æ } d
 \ } } | | k  rñ | | } n  | | k  r
|  | } n  | d k  s"| d k  r4t  j
 d ƒ ‚ n  | | | | t |	 | ƒ } } }	 | d k r†|
 j d | d | | f ƒ qÆ | d k rÆ | j d | | f ƒ qÆ qÆ W| | k rÎt  j
 d ƒ ‚ n  t j |
 ƒ t j | ƒ d g |	 d } xË|
 rÆt j |
 ƒ \ } } } | d 9} | t |
 ƒ t | ƒ k rRt  j
 d ƒ ‚ n  d } xá t	 | ƒ D]Ó } | r²|
 s”|
 d d | d d k r²t j | ƒ \ } } d } n t j |
 ƒ \ } } } | d k rèt  j
 d ƒ ‚ n  | j | | ƒ | d d k  s| d k  re| d | | f | | <| d 7} qeqeWx_ t	 | ƒ D]Q } | | } | d d k  r|t j |
 | ƒ qIt j | | d | d f ƒ qIW| d k  rüt j | | | f ƒ qüqüWd | j ƒ  | j ƒ  f | _ | S(   s  Return a directed graph with the given degree sequences.

    Parameters
    ----------
    in_deg_sequence :  list of integers 
       Each list entry corresponds to the in-degree of a node.
    out_deg_sequence : list of integers 
       Each list entry corresponds to the out-degree of a node.
    create_using : graph, optional (default DiGraph)
       Return graph of this type. The instance will be cleared.

    Returns
    -------
    G : DiGraph
        A graph with the specified degree sequences.
        Nodes are labeled starting at 0 with an index
        corresponding to the position in deg_sequence

    Raises
    ------
    NetworkXError
        If the degree sequences are not digraphical.

    See Also
    --------
    configuration_model
    
    Notes
    -----
    Algorithm as described by Kleitman and Wang [1]_.

    References
    ----------
    .. [1] D.J. Kleitman and D.L. Wang
       Algorithms for Constructing Graphs and Digraphs with Given Valences
       and Factors Discrete Mathematics, 6(1), pp. 79-88 (1973) 
    i    s;   Invalid degree sequences. Sequence values must be positive.iÿÿÿÿs9   Invalid degree sequences. Sequences must have equal sums.i   s    Non-digraphical integer sequencei   s-   directed_havel_hakimi_graph %d nodes %d edgesN(   i    i    (   i    i    i    (   R   t   utilst   is_list_of_intst   AssertionErrorR   t   DiGraphR   R   R   R   R   R   t   heapqt   heapifyt   heappopR   t   heappushR   R   R   (   t   in_deg_sequencet   out_deg_sequenceR   t   sumint   sumoutR+   R,   t   maxnR!   t   maxint   stubheapt   zeroheapR#   t   in_degt   out_degRP   t   freeoutt   freeinR0   RQ   R$   t   stuboutt
   stubsourcet   stubint   stub(    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyR   à  sr    (*%!	
)	
"c   
      C   sy  t  |  ƒ t |  ƒ d d k s2 t j d ƒ ‚ n  | d	 k	 r\ | j ƒ  r\ t j d ƒ ‚ n  t  |  ƒ d k r„ t j d | ƒ } | Sg  |  D] } | d k r‹ | ^ q‹ } | j d t ƒ t  | ƒ d } t j	 | | ƒ } | } xc t
 d | d ƒ D]N } | j ƒ  d } x+ t
 | | | ƒ D] }	 | j | |	 ƒ qW| | 7} qõ Wt  | j ƒ  ƒ t  |  ƒ k ru| j d ƒ n  | S(
   s    Make a tree for the given degree sequence.

    A tree has #nodes-#edges=1 so
    the degree sequence must have
    len(deg_sequence)-sum(deg_sequence)/2=1
    g       @g      ð?s   Degree sequence invalids   Directed Graph not supportedi   i    R2   i   N(   R   R   R   R   R   R   R   t   sortR9   t
   path_graphR   R   R   t   degreet   remove_node(
   R   R   R!   t   st   degR#   RF   R/   t   nedgesR0   (    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyR	   Q  s(     %i
   c         C   se   t  |  d | ƒ} x9 t | ƒ D]+ } y | j ƒ  SWq t j k
 rI q Xq Wt j d | ƒ ‚ d S(   s¤  Return a simple random graph with the given degree sequence.

    If the maximum degree `d_m` in the sequence is `O(m^{1/4})` then the
    algorithm produces almost uniform random graphs in `O(m d_m)` time
    where `m` is the number of edges.

    Parameters
    ----------
    sequence :  list of integers
        Sequence of degrees
    seed : hashable object, optional
        Seed for random number generator
    tries : int, optional
        Maximum number of tries to create a graph

    Returns
    -------
    G : Graph
        A graph with the specified degree sequence.
        Nodes are labeled starting at 0 with an index
        corresponding to the position in the sequence.

    Raises
    ------
    NetworkXUnfeasible
        If the degree sequence is not graphical.
    NetworkXError
        If a graph is not produced in specified number of tries

    See Also
    --------
    is_valid_degree_sequence, configuration_model

    Notes
    -----
    The generator algorithm [1]_ is not guaranteed to produce a graph.

    References
    ----------
    .. [1] Moshen Bayati, Jeong Han Kim, and Amin Saberi,
       A sequential algorithm for generating random graphs.
       Algorithmica, Volume 58, Number 4, 860-910,
       DOI: 10.1007/s00453-009-9340-1

    Examples
    --------
    >>> sequence = [1, 2, 2, 3]
    >>> G = nx.random_degree_sequence_graph(sequence)
    >>> sorted(G.degree().values())
    [1, 2, 2, 3]
    R   s$   failed to generate graph in %d triesN(   t   DegreeSequenceRandomGraphR   t   generateR   t   NetworkXUnfeasibleR   (   t   sequenceR   t   triest   DSRGt   try_n(    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyR
   x  s    4Rt   c           B   s_   e  Z d	 d  „ Z d „  Z d	 d „ Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z RS(
   c         C   s™   t  j | ƒ s! t  j d ƒ ‚ n  | d  k	 r= t j | ƒ n  t | ƒ |  _ t |  j ƒ d |  _	 y t
 |  j ƒ |  _ Wn t k
 r” d |  _ n Xd  S(   Ns    degree sequence is not graphicalg       @i    (   R   RK   Rv   R   R   R   t   listRo   R   t   mR   RM   t
   ValueError(   t   selfRo   R   (    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyt   __init__·  s    c         C   s¶   t  t |  j ƒ ƒ |  _ t j ƒ  |  _ |  j j |  j ƒ x< t |  j j	 ƒ  ƒ D]% \ } } | d k rP |  j | =qP qP Wt
 |  j ƒ d k r¯ |  j ƒ  |  j ƒ  |  j ƒ  n  |  j S(   Ni    (   R:   R8   Ro   t   remaining_degreeR   t   Grapht   grapht   add_nodes_fromR{   t   itemsR   t   phase1t   phase2t   phase3(   R~   R#   RO   (    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyRu   Ä  s    "

c         C   sÁ   | d  k	 r | j | | ƒ n  |  j | d k r[ |  j | =| d  k	 rn | j | ƒ qn n |  j | c d 8<|  j | d k rª |  j | =| d  k	 r½ | j | ƒ q½ n |  j | c d 8<d  S(   Ni   (   R   t   remove_edgeR€   Rp   (   R~   RC   RD   t	   aux_graph(    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyt   update_remainingÕ  s    

c         C   s%   d |  j  | |  j  | d |  j S(   Ni   g      @(   Ro   R|   (   R~   RC   RD   (    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyRH   ç  s    c         C   s9   t  t |  j j ƒ  ƒ ƒ d } |  j | |  j | | S(   Ni   (   R6   R   R€   t   values(   R~   RC   RD   t   norm(    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyRJ   ë  s    c         C   sI   t  |  j ƒ } t | ƒ } x' | D] } |  j j | | ƒ s" t Sq" Wt S(   N(   t   iterR€   t   nextR‚   t   has_edgeR9   t   False(   R~   t   nodesRC   RD   (    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyt   suitable_edgeð  s    c         C   s®   x§ t  |  j j ƒ  ƒ d |  j d k r© t t |  j d ƒ ƒ \ } } |  j j | | ƒ rb q n  t j ƒ  |  j	 | | ƒ k  r |  j j
 | | ƒ |  j | | ƒ q q Wd  S(   Ni   (   R   R€   R‹   RM   R7   R   R‚   R�   R   RH   R   RŠ   (   R~   RC   RD   (    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyR…   û  s    )c         C   sû   xô t  |  j ƒ d |  j k rö t t |  j j ƒ  ƒ ƒ d } xn t r® t t j	 |  j j
 ƒ  d ƒ ƒ \ } } |  j j | | ƒ r‰ qA n  t j ƒ  |  j | | ƒ k  rA PqA qA Wt j ƒ  |  j | | ƒ k  r |  j j | | ƒ |  j | | ƒ q q Wd  S(   Ni   (   R   R€   RM   R6   R   R‹   R9   R7   R   t   samplet   keysR‚   R�   RJ   RH   R   RŠ   (   R~   RŒ   RC   RD   (    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyR†     s    	'c         C   s!  t  |  j d ƒ } t j g  | D]- \ } } |  j j | | ƒ s | | f ^ q ƒ } xÅ |  j r|  j ƒ  s t j d ƒ ‚ n  xM t rÎ t	 t
 j | j ƒ  ƒ ƒ \ } } t
 j
 ƒ  |  j | | ƒ k  r‚ Pq‚ q‚ Wt
 j
 ƒ  |  j | | ƒ k  rX |  j j | | ƒ |  j | | d | ƒqX qX Wd  S(   Ni   s   no suitable edges leftR‰   (   R    R€   R   R�   R‚   R�   R’   Rv   R9   R7   R   t   choicet   edgesRJ   RH   R   RŠ   (   R~   t   potential_edgesRC   RD   t   H(    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyR‡     s    *	!N(   t   __name__t
   __module__R   R   Ru   RŠ   RH   RJ   R’   R…   R†   R‡   (    (    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyRt   ´  s   					
	(   t   __doc__RY   t	   itertoolsR    R   R<   t   operatorR   R   t   networkxR   t   networkx.utilsR   t   joint
   __author__t   __all__R   R   R   R9   R   R   R   R	   R
   t   objectRt   (    (    (    sr   /home/gitlab-runner/builds/8480fa44/0/bergerc/fluidmanager-web/art-framework/bin/networkx/generators/degree_seq.pyt   <module>   s4   		u~lao'<