code: def vertex_graph(entities):
      
      graph = nx.Graph()
      closed = []
      for index, entity in enumerate(entities):
          if entity.closed:
              closed.append(index)
          else:
              graph.add_edges_from(entity.nodes,
                                   entity_index=index)
      return graph, np.array(closed)
docs: Given a set of entity objects generate a networkx.Graph
      that represents their vertex nodes.
  
      Parameters
      --------------
      entities : list
         Objects with 'closed' and 'nodes' attributes
  
      Returns
      -------------
      graph : networkx.Graph
          Graph where node indexes represent vertices
      closed : (n,) int
          Indexes of entities which are 'closed'