code: def build_graph_from_triplets(num_nodes, num_rels, triplets):
      """Create a DGL graph. The graph is bidirectional because RGCN authors
      use reversed relations.
      This function also generates edge type and normalization factor
      (reciprocal of node incoming degree)
      """
      g = dgl.DGLGraph()
      g.add_nodes(num_nodes)
      src, rel, dst = triplets
      src, dst = np.concatenate((src, dst)), np.concatenate((dst, src))
      rel = np.concatenate((rel, rel + num_rels))
      edges = sorted(zip(dst, src, rel))
      dst, src, rel = np.array(edges).transpose()
      g.add_edges(src, dst)
      norm = comp_deg_norm(g)
      print("# nodes: {}, # edges: {}".format(num_nodes, len(src)))
      return g, rel, norm
  
file_path: dgl/examples/tensorflow/rgcn/utils.py
imports: import dgl
  import numpy
  import tensorflow
label_desc: Use image node_id 6 for calling a global function with example usage: build_graph_from_triplets(num_nodes, num_rels, triplets) and returns: g,  rel,  norm