code: def miles_graph():
      """Return the cites example graph in miles_dat.txt
      from the Stanford GraphBase.
      """
      # open file miles_dat.txt.gz (or miles_dat.txt)
  
      fh = gzip.open("knuth_miles.txt.gz", "r")
  
      G = nx.Graph()
      G.position = {}
      G.population = {}
  
      cities = []
      for line in fh.readlines():
          line = line.decode()
          if line.startswith("*"):  # skip comments
              continue
  
          numfind = re.compile(r"^\d+")
  
          if numfind.match(line):  # this line is distances
              dist = line.split()
              for d in dist:
                  G.add_edge(city, cities[i], weight=int(d))
                  i = i + 1
          else:  # this line is a city, position, population
              i = 1
              (city, coordpop) = line.split("[")
              cities.insert(0, city)
              (coord, pop) = coordpop.split("]")
              (y, x) = coord.split(",")
  
              G.add_node(city)
              # assign position - Convert string to lat/long
              G.position[city] = (-float(x) / 100, float(y) / 100)
              G.population[city] = float(pop) / 1000
      return G
  
imports: import gzip
  import re
  import warnings
  import numpy
  import matplotlib.pyplot
  import networkx
label_desc: Use image node_id 1 for calling a global function with example usage: miles_graph() and returns: G