def ring_of_cliques(num_cliques, clique_size):
 if (num_cliques < 2):
  raise nx.NetworkXError('A ring of cliques must have at least two cliques')
 if (clique_size < 2):
  raise nx.NetworkXError('The cliques must have at least two nodes')
 G = nx.Graph()
 for i in range(num_cliques):
  edges = itertools.combinations(range((i * clique_size), ((i * clique_size) + clique_size)), 2)
  G.add_edges_from(edges)
  G.add_edge(((i * clique_size) + 1), (((i + 1) * clique_size) % (num_cliques * clique_size)))
 return G

def ring_of_cliques ( num_cliques , clique_size ) : if ( num_cliques < 2 ) : raise nx . NetworkXError ( 'A ring of cliques must have at least two cliques' ) if ( clique_size < 2 ) : raise nx . NetworkXError ( 'The cliques must have at least two nodes' ) G = nx . Graph ( ) for i in range ( num_cliques ) : edges = itertools . combinations ( range ( ( i * clique_size ) , ( ( i * clique_size ) + clique_size ) ) , 2 ) G . add_edges_from ( edges ) G . add_edge ( ( ( i * clique_size ) + 1 ) , ( ( ( i + 1 ) * clique_size ) % ( num_cliques * clique_size ) ) ) return G
defines a "ring of cliques" graph .