class_docstr: Implemetation of graph in order to sample metapath random walk.
      
docstr: Build pgl heterogeneous graph.
          
docstr_tok: ["Build","pgl","heterogeneous","graph","."]
code: def build_graph(self):
      """Build pgl heterogeneous graph."""
      edges_by_types = {}
      npy = self.edge_file_list[0][1] + ".npy"
      if os.path.exists(npy):
          log.info("load data from numpy file")
  
          for pair in self.edge_file_list:
              edges_by_types[pair[0]] = np.load(pair[1] + ".npy")
  
      else:
          log.info("load data from txt file")
          for pair in self.edge_file_list:
              edges_by_types[pair[0]] = self.load_edges(pair[1])
              #  np.save(pair[1] + ".npy", edges_by_types[pair[0]])
  
      for e_type, edges in edges_by_types.items():
          log.info(["number of %s edges: " % e_type, len(edges)])
  
      if self.symmetry:
          tmp = {}
          for key, edges in edges_by_types.items():
              n_list = key.split("2")
              re_key = n_list[1] + "2" + n_list[0]
              tmp[re_key] = edges_by_types[key][:, [1, 0]]
          edges_by_types.update(tmp)
  
      log.info(["finished loadding symmetry edges."])
  
      node_types = self.load_node_types(self.node_types_file)
  
      assert (
          len(node_types) == self.num_nodes
      ), "num_nodes should be equal to the length of node_types"
      log.info(["number of nodes: ", len(node_types)])
  
      node_features = {
          "index": np.array([i for i in range(self.num_nodes)])
          .reshape(-1, 1)
          .astype(np.int64)
      }
  
      self.graph = heter_graph.HeterGraph(
          num_nodes=self.num_nodes,
          edges=edges_by_types,
          node_types=node_types,
          node_feat=node_features,
      )
  
file_path: PGL/legacy/examples/distribute_metapath2vec/graph.py
imports: import argparse
  import sys
  import os
  import numpy
  import pickle
  import tqdm
  import time
  import random
  from pgl.utils.logger import log
  from pgl import heter_graph
label_desc: Use image node_id 2 for calling the m2vGraph obj's underlying member method code with example usage: obj.build_graph() without return types