code: def edges_to_polygons(edges, vertices):
      
  
      # create closed polygon objects
      polygons = []
      # loop through a sequence of ordered traversals
      for dfs in graph.traversals(edges, mode='dfs'):
          try:
              # try to recover polygons before they are more complicated
              polygons.append(repair_invalid(Polygon(vertices[dfs])))
          except ValueError:
              continue
  
      # if there is only one polygon, just return it
      if len(polygons) == 1:
          return polygons
  
      # find which polygons contain which other polygons
      roots, tree = enclosure_tree(polygons)
  
      # generate list of polygons with proper interiors
      complete = []
      for root in roots:
          interior = list(tree[root].keys())
          shell = polygons[root].exterior.coords
          holes = [polygons[i].exterior.coords for i in interior]
          complete.append(Polygon(shell=shell,
                                  holes=holes))
      return complete
docs: Given an edge list of indices and associated vertices
      representing lines, generate a list of polygons.
  
      Parameters
      -----------
      edges : (n, 2) int
        Indexes of vertices which represent lines
      vertices : (m, 2) float
        Vertices in 2D space
  
      Returns
      ----------
      polygons : (p,) shapely.geometry.Polygon
        Polygon objects with interiors