def chordal_cycle_graph(p, create_using=None):
 if (create_using is None):
  create_using = nx.MultiGraph()
 elif (create_using.is_directed() or (not create_using.is_multigraph())):
  msg = '`create_using` must be an undirected multigraph.'
  raise nx.NetworkXError(msg)
 G = create_using
 G.clear()
 for x in range(p):
  left = ((x - 1) % p)
  right = ((x + 1) % p)
  chord = (pow(x, (p - 2), p) if (x > 0) else 0)
  for y in (left, right, chord):
   G.add_edge(x, y)
 G.graph['name'] = 'chordal_cycle_graph({0})'.format(p)
 return G

def chordal_cycle_graph ( p , create_using = None ) : if ( create_using is None ) : create_using = nx . MultiGraph ( ) elif ( create_using . is_directed ( ) or ( not create_using . is_multigraph ( ) ) ) : msg = '`create_using` must be an undirected multigraph.' raise nx . NetworkXError ( msg ) G = create_using G . clear ( ) for x in range ( p ) : left = ( ( x - 1 ) % p ) right = ( ( x + 1 ) % p ) chord = ( pow ( x , ( p - 2 ) , p ) if ( x > 0 ) else 0 ) for y in ( left , right , chord ) : G . add_edge ( x , y ) G . graph [ 'name' ] = 'chordal_cycle_graph({0})' . format ( p ) return G
return the chordal cycle graph on p nodes .