def dorogovtsev_goltsev_mendes_graph(n, create_using=None):
 if (create_using is not None):
  if create_using.is_directed():
   raise nx.NetworkXError('Directed Graph not supported')
  if create_using.is_multigraph():
   raise nx.NetworkXError('Multigraph not supported')
 G = empty_graph(0, create_using)
 G.name = 'Dorogovtsev-Goltsev-Mendes Graph'
 G.add_edge(0, 1)
 if (n == 0):
  return G
 new_node = 2
 for i in range(1, (n + 1)):
  last_generation_edges = list(G.edges())
  number_of_edges_in_last_generation = len(last_generation_edges)
  for j in range(0, number_of_edges_in_last_generation):
   G.add_edge(new_node, last_generation_edges[j][0])
   G.add_edge(new_node, last_generation_edges[j][1])
   new_node += 1
 return G

def dorogovtsev_goltsev_mendes_graph ( n , create_using = None ) : if ( create_using is not None ) : if create_using . is_directed ( ) : raise nx . NetworkXError ( 'Directed Graph not supported' ) if create_using . is_multigraph ( ) : raise nx . NetworkXError ( 'Multigraph not supported' ) G = empty_graph ( 0 , create_using ) G . name = 'Dorogovtsev-Goltsev-Mendes Graph' G . add_edge ( 0 , 1 ) if ( n == 0 ) : return G new_node = 2 for i in range ( 1 , ( n + 1 ) ) : last_generation_edges = list ( G . edges ( ) ) number_of_edges_in_last_generation = len ( last_generation_edges ) for j in range ( 0 , number_of_edges_in_last_generation ) : G . add_edge ( new_node , last_generation_edges [ j ] [ 0 ] ) G . add_edge ( new_node , last_generation_edges [ j ] [ 1 ] ) new_node += 1 return G
return the hierarchically constructed dorogovtsev-goltsev-mendes graph .