class_docstr: Redis Heterogeneous Graph
class_docstr_tok: ["Redis","Heterogeneous","Graph"]
docstr: Generate heterogeneous subgraph with nodes and edge ids.
  
  WARNING: ALL NODES IN EID MUST BE INCLUDED BY NODES
  
  Args:
      nodes: Node ids which will be included in the subgraph.
  
      eid: Edge ids which will be included in the subgraph.
  
  Return:
      A :code:`pgl.heter_graph.Subgraph` object.
docstr_tok: ["Generate","heterogeneous","subgraph","with","nodes","and","edge","ids",".","WARNING",":","ALL","NODES","IN","EID","MUST","BE","INCLUDED","BY","NODES","Args",":","nodes",":","Node","ids","which","will","be","included","in","the","subgraph",".","eid",":","Edge","ids","which","will","be","included","in","the","subgraph",".","Return",":","A",":","code",":","`","pgl.heter_graph.Subgraph","`","object","."]
code: def subgraph(self, nodes, eid, edges=None):
      """Generate heterogeneous subgraph with nodes and edge ids.
  
      WARNING: ALL NODES IN EID MUST BE INCLUDED BY NODES
  
      Args:
          nodes: Node ids which will be included in the subgraph.
  
          eid: Edge ids which will be included in the subgraph.
  
      Return:
          A :code:`pgl.heter_graph.Subgraph` object.
      """
      reindex = {}
  
      for ind, node in enumerate(nodes):
          reindex[node] = ind
  
      _node_types = self.get_node_types(nodes)
      if _node_types is None:
          node_types = None
      else:
          node_types = []
          for idx, t in zip(nodes, _node_types):
              node_types.append([reindex[idx], t])
  
      if edges is None:
          edges = {}
          for e_type, eid_list in eid.items():
              edges[e_type] = self.get_edges_by_id(e_type, eid_list)
  
      sub_edges = {}
      for e_type, edges_list in edges.items():
          sub_edges[e_type] = graph_kernel.map_edges(
              np.arange(len(edges_list), dtype="int64"),
              edges_list,
              reindex,
          )
  
      sub_edge_feat = {}
      for e_type, edge_feat_info in self.edge_feat_info().items():
          type_edge_feat = {}
          for key, _, _ in edge_feat_info:
              type_edge_feat[key] = self.get_edge_feat_by_id(
                  e_type, key, eid
              )
          sub_edge_feat[e_type] = type_edge_feat
  
      sub_node_feat = {}
      for key, _, _ in self.node_feat_info():
          sub_node_feat[key] = self.get_node_feat_by_id(key, nodes)
  
      subgraph = heter_graph.SubHeterGraph(
          num_nodes=len(nodes),
          edges=sub_edges,
          node_types=node_types,
          node_feat=sub_node_feat,
          edge_feat=sub_edge_feat,
          reindex=reindex,
      )
      return subgraph
  
imports: import pgl
  import redis
  from redis import BlockingConnectionPool, StrictRedis
  from redis._compat import b, unicode, bytes, long, basestring
  from rediscluster.nodemanager import NodeManager
  from rediscluster.crc import crc16
  from collections import OrderedDict
  import threading
  import numpy
  import time
  import json
  import pgl.graph
  import pickle
  from pgl.utils.logger import log
  import pgl.graph_kernel
  from pgl import heter_graph
  import pgl.redis_graph
label_desc: Use image node_id 15 for calling the RedisHeterGraph obj's underlying member method code with example usage: obj.subgraph(nodes, eid, edges) and returns: subgraph