def _configuration_model(deg_sequence, create_using, directed=False, in_deg_sequence=None, seed=None):
 if (seed is not None):
  random.seed(seed)
 n = len(deg_sequence)
 G = nx.empty_graph(n, create_using=create_using)
 if (n == 0):
  return G
 if directed:
  pairs = zip_longest(deg_sequence, in_deg_sequence, fillvalue=0)
  (out_deg, in_deg) = zip(*pairs)
  out_stublist = _to_stublist(out_deg)
  in_stublist = _to_stublist(in_deg)
  random.shuffle(out_stublist)
  random.shuffle(in_stublist)
 else:
  stublist = _to_stublist(deg_sequence)
  n = len(stublist)
  half = (n // 2)
  random.shuffle(stublist)
  (out_stublist, in_stublist) = (stublist[:half], stublist[half:])
 G.add_edges_from(zip(out_stublist, in_stublist))
 return G

def _configuration_model ( deg_sequence , create_using , directed = False , in_deg_sequence = None , seed = None ) : if ( seed is not None ) : random . seed ( seed ) n = len ( deg_sequence ) G = nx . empty_graph ( n , create_using = create_using ) if ( n == 0 ) : return G if directed : pairs = zip_longest ( deg_sequence , in_deg_sequence , fillvalue = 0 ) ( out_deg , in_deg ) = zip ( * pairs ) out_stublist = _to_stublist ( out_deg ) in_stublist = _to_stublist ( in_deg ) random . shuffle ( out_stublist ) random . shuffle ( in_stublist ) else : stublist = _to_stublist ( deg_sequence ) n = len ( stublist ) half = ( n // 2 ) random . shuffle ( stublist ) ( out_stublist , in_stublist ) = ( stublist [ : half ] , stublist [ half : ] ) G . add_edges_from ( zip ( out_stublist , in_stublist ) ) return G
helper function for generating either undirected or directed configuration model graphs .