def configuration_model(aseq, bseq, create_using=None, seed=None):
 if (create_using is None):
  create_using = networkx.MultiGraph()
 elif create_using.is_directed():
  raise networkx.NetworkXError('Directed Graph not supported')
 G = networkx.empty_graph(0, create_using)
 if (not (seed is None)):
  random.seed(seed)
 lena = len(aseq)
 lenb = len(bseq)
 suma = sum(aseq)
 sumb = sum(bseq)
 if (not (suma == sumb)):
  raise networkx.NetworkXError(('invalid degree sequences, sum(aseq)!=sum(bseq),%s,%s' % (suma, sumb)))
 G = _add_nodes_with_bipartite_label(G, lena, lenb)
 if (max(aseq) == 0):
  return G
 stubs = []
 stubs.extend([([v] * aseq[v]) for v in range(0, lena)])
 astubs = []
 astubs = [x for subseq in stubs for x in subseq]
 stubs = []
 stubs.extend([([v] * bseq[(v - lena)]) for v in range(lena, (lena + lenb))])
 bstubs = []
 bstubs = [x for subseq in stubs for x in subseq]
 random.shuffle(astubs)
 random.shuffle(bstubs)
 G.add_edges_from([[astubs[i], bstubs[i]] for i in range(suma)])
 G.name = 'bipartite_configuration_model'
 return G

def configuration_model ( aseq , bseq , create_using = None , seed = None ) : if ( create_using is None ) : create_using = networkx . MultiGraph ( ) elif create_using . is_directed ( ) : raise networkx . NetworkXError ( 'Directed Graph not supported' ) G = networkx . empty_graph ( 0 , create_using ) if ( not ( seed is None ) ) : random . seed ( seed ) lena = len ( aseq ) lenb = len ( bseq ) suma = sum ( aseq ) sumb = sum ( bseq ) if ( not ( suma == sumb ) ) : raise networkx . NetworkXError ( ( 'invalid degree sequences, sum(aseq)!=sum(bseq),%s,%s' % ( suma , sumb ) ) ) G = _add_nodes_with_bipartite_label ( G , lena , lenb ) if ( max ( aseq ) == 0 ) : return G stubs = [ ] stubs . extend ( [ ( [ v ] * aseq [ v ] ) for v in range ( 0 , lena ) ] ) astubs = [ ] astubs = [ x for subseq in stubs for x in subseq ] stubs = [ ] stubs . extend ( [ ( [ v ] * bseq [ ( v - lena ) ] ) for v in range ( lena , ( lena + lenb ) ) ] ) bstubs = [ ] bstubs = [ x for subseq in stubs for x in subseq ] random . shuffle ( astubs ) random . shuffle ( bstubs ) G . add_edges_from ( [ [ astubs [ i ] , bstubs [ i ] ] for i in range ( suma ) ] ) G . name = 'bipartite_configuration_model' return G
return a random graph with the given degree sequence .