original_docstring:   Return the metric closure of a graph.
  
      The metric closure of a graph *G* is the complete graph in which each edge
      is weighted by the shortest path distance between the nodes in *G* .
  
      Parameters
      ----------
      G : NetworkX graph
  
      Returns
      -------
      NetworkX graph
          Metric closure of the graph `G`.
  
      
docstring: Return the metric closure of a graph.
  The metric closure of a graph *G* is the complete graph in which each edge
  is weighted by the shortest path distance between the nodes in *G* .
  
  Parameters
  
  G : NetworkX graph
  
  Returns
  
  NetworkX graph
  Metric closure of the graph `G`.
docstring_tokens: Return the metric closure of a graph . The metric closure of a graph * G * is the complete graph in which each edge is weighted by the shortest path distance between the nodes in * G * . Parameters G : NetworkX graph Returns NetworkX graph Metric closure of the graph ` G ` .
code: def metric_closure(G, weight='weight'):
      """  Return the metric closure of a graph.
  
      The metric closure of a graph *G* is the complete graph in which each edge
      is weighted by the shortest path distance between the nodes in *G* .
  
      Parameters
      ----------
      G : NetworkX graph
  
      Returns
      -------
      NetworkX graph
          Metric closure of the graph `G`.
  
      """
      M = nx.Graph()
  
      seen = set()
      Gnodes = set(G)
      for u, (distance, path) in nx.all_pairs_dijkstra(G, weight=weight):
          seen.add(u)
          for v in Gnodes - seen:
              M.add_edge(u, v, distance=distance[v], path=path[v])
  
      return M
code_tokens: def metric_closure ( G , weight = 'weight' ) : M = nx . Graph ( ) seen = set ( ) Gnodes = set ( G ) for u , ( distance , path ) in nx . all_pairs_dijkstra ( G , weight = weight ) : seen . add ( u ) for v in Gnodes - seen : M . add_edge ( u , v , distance = distance [ v ] , path = path [ v ] ) return M
short_docstring: Return the metric closure of a graph.
short_docstring_tokens: Return the metric closure of a graph .
comment: """  Return the metric closure of a graph.
  
      The metric closure of a graph *G* is the complete graph in which each edge
      is weighted by the shortest path distance between the nodes in *G* .
  
      Parameters
      ----------
      G : NetworkX graph
  
      Returns
      -------
      NetworkX graph
          Metric closure of the graph `G`.
  
      """