class_docstr: EPGM class with converter methods to edgelist, adjacency matrix, etc.
class_docstr_tok: ["EPGM","class","with","converter","methods","to","edgelist",",","adjacency","matrix",",","etc","."]
docstr: Convert the graph specified by its graph_id to networkx Directed Multi-graph
docstr_tok: ["Convert","the","graph","specified","by","its","graph_id","to","networkx","Directed","Multi-graph"]
code: def to_nx(self, graph_id, directed=False, *args):
      """Convert the graph specified by its graph_id to networkx Directed Multi-graph"""
  
      if (
          False
      ):  # graph_id in self.G_nx.keys():  # if self.G_nx[graph_id] already exists, just return it, otherwise evaluate it
          return self.G_nx[graph_id]
      else:  # we always re-calculate self.G_nx, since directed argument can change
          print(
              "Converting the EPGM graph {} to NetworkX graph...".format(
                  graph_id
              )
          )
          if not any([graph_id in g["id"] for g in self.G["graphs"]]):
              raise Exception(
                  "Graph with id {} does not exist".format(graph_id)
              )
  
      self.G_nx[
          graph_id
      ] = (
          nx.MultiDiGraph()
      )  # create an empty directed graph that can store multiedges
      # add nodes to self.G_nx[graph_id], together with their attributes stored in 'data':
      self.G_nx[graph_id].add_nodes_from(
          [
              (
                  v["id"],
                  {
                      **v["data"],
                      **{"label": v["meta"].get("label", "")},
                  },
              )
              for v in self.G["vertices"]
          ]
      )
      # add edges to self.G_nx[graph_id], together with their attributes stored in 'data':
      # I have added the edge label in the edge data; sets the label to '' if the edges don't have a label
      self.G_nx[graph_id].add_edges_from(
          [
              (
                  e["source"],
                  e["target"],
                  e["id"],
                  {
                      **e["data"],
                      **{"label": e["meta"].get("label", "")},
                  },
              )
              for e in self.G["edges"]
          ]
      )
  
      if not directed:
          self.G_nx[graph_id] = self.G_nx[graph_id].to_undirected()
  
      return self.G_nx[graph_id]
  
imports: from collections import OrderedDict
  import networkx
  from networkx.readwrite import json_graph
  import os
  import json
  import uuid
  import numpy
  import scipy.sparse
  import multiprocessing
  from multiprocessing import Pool
  from functools import partial
  from time import sleep
label_desc: Use image node_id 13 for calling the EPGM obj's underlying member method code with example usage: obj.to_nx(graph_id, directed) and returns: self, self