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: Create G_epmg from G_json
docstr_tok: ["Create","G_epmg","from","G_json"]
code: def _json_to_epgm(self, G_json, node_attributes, node_labels):
      """Create G_epmg from G_json"""
  
      G_epgm = {
          "graphs": [OrderedDict()],
          "vertices": [OrderedDict(n) for n in G_json["nodes"]],
          "edges": [OrderedDict(e) for e in G_json["links"]],
      }
  
      # update G_epgm['graphs']:
      G_epgm["graphs"][0].update(
          OrderedDict(
              [
                  ("id", G_json["graph"]["id"]),
                  ("data", {}),
                  (
                      "meta",
                      {"label": G_json["graph"].get("name", "unnamed")},
                  ),
              ]
          )
      )
  
      # update G_epgm['vertices']:
      if node_labels is None:
          node_labels = [""] * len(G_epgm["vertices"])
      for ind, v in enumerate(G_epgm["vertices"]):
          if node_attributes is not None:
              data = {
                  str(k): str(v)
                  for k, v in node_attributes.iloc[ind].items()
                  if v != 0
              }  # extract non-zero node attributes (sparse node attributes)
          else:
              data = {}
          v.update(
              OrderedDict(
                  [
                      ("data", data),
                      (
                          "meta",
                          {
                              "label": str(node_labels[ind]),
                              "graphs": [G_json["graph"]["id"]],
                          },
                      ),
                  ]
              )
          )
  
      # update G_epgm['edges']:
      edges_key_order = ["id", "source", "target", "data", "meta"]
      for e in G_epgm["edges"]:
          e.update(
              OrderedDict(
                  [
                      ("id", uuid.uuid4().hex),
                      ("data", {}),
                      (
                          "meta",
                          {
                              "label": "",
                              "graphs": [G_json["graph"]["id"]],
                          },
                      ),
                  ]
              )
          )
      # reorder keys in e to edges_key_order:
      G_epgm["edges"] = [
          OrderedDict((k, e[k]) for k in edges_key_order)
          for e in G_epgm["edges"]
      ]
  
      return G_epgm
  
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 4 for calling the EPGM obj's underlying member method code with example usage: obj._json_to_epgm(G_json, node_attributes, node_labels) and returns: G_epgm