def margulis_gabber_galil_graph(n, 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, y) in itertools.product(range(n), repeat=2):
  for (u, v) in ((((x + (2 * y)) % n), y), (((x + ((2 * y) + 1)) % n), y), (x, ((y + (2 * x)) % n)), (x, ((y + ((2 * x) + 1)) % n))):
   G.add_edge((x, y), (u, v))
 G.graph['name'] = 'margulis_gabber_galil_graph({0})'.format(n)
 return G

def margulis_gabber_galil_graph ( n , 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 , y ) in itertools . product ( range ( n ) , repeat = 2 ) : for ( u , v ) in ( ( ( ( x + ( 2 * y ) ) % n ) , y ) , ( ( ( x + ( ( 2 * y ) + 1 ) ) % n ) , y ) , ( x , ( ( y + ( 2 * x ) ) % n ) ) , ( x , ( ( y + ( ( 2 * x ) + 1 ) ) % n ) ) ) : G . add_edge ( ( x , y ) , ( u , v ) ) G . graph [ 'name' ] = 'margulis_gabber_galil_graph({0})' . format ( n ) return G
return the margulis-gabber-galil undirected multigraph on n^2 nodes .