def complete_multipartite_graph(*subset_sizes):
 G = nx.Graph()
 G.name = 'complete_multiparite_graph{}'.format(subset_sizes)
 if (len(subset_sizes) == 0):
  return G
 try:
  extents = pairwise(accumulate(((0,) + subset_sizes)))
  subsets = [range(start, end) for (start, end) in extents]
 except TypeError:
  subsets = subset_sizes
 try:
  for (i, subset) in enumerate(subsets):
   G.add_nodes_from(subset, subset=i)
 except TypeError:
  raise nx.NetworkXError('Arguments must be all ints or all iterables')
 for (subset1, subset2) in itertools.combinations(subsets, 2):
  G.add_edges_from(itertools.product(subset1, subset2))
 return G

def complete_multipartite_graph ( * subset_sizes ) : G = nx . Graph ( ) G . name = 'complete_multiparite_graph{}' . format ( subset_sizes ) if ( len ( subset_sizes ) == 0 ) : return G try : extents = pairwise ( accumulate ( ( ( 0 , ) + subset_sizes ) ) ) subsets = [ range ( start , end ) for ( start , end ) in extents ] except TypeError : subsets = subset_sizes try : for ( i , subset ) in enumerate ( subsets ) : G . add_nodes_from ( subset , subset = i ) except TypeError : raise nx . NetworkXError ( 'Arguments must be all ints or all iterables' ) for ( subset1 , subset2 ) in itertools . combinations ( subsets , 2 ) : G . add_edges_from ( itertools . product ( subset1 , subset2 ) ) return G
returns the complete multipartite graph with the specified subset sizes .