def circulant_graph(n, offsets, create_using=None):
 G = empty_graph(n, create_using)
 template = 'circulant_graph(%d, [%s])'
 G.name = (template % (n, ', '.join((str(j) for j in offsets))))
 for i in range(n):
  for j in offsets:
   G.add_edge(i, ((i - j) % n))
   G.add_edge(i, ((i + j) % n))
 return G

def circulant_graph ( n , offsets , create_using = None ) : G = empty_graph ( n , create_using ) template = 'circulant_graph(%d, [%s])' G . name = ( template % ( n , ', ' . join ( ( str ( j ) for j in offsets ) ) ) ) for i in range ( n ) : for j in offsets : G . add_edge ( i , ( ( i - j ) % n ) ) G . add_edge ( i , ( ( i + j ) % n ) ) return G
generates the circulant graph ci_n with n vertices .