class_docstr: Implementation of graph structure in pgl.
  
  This is a simple implementation of graph structure in pgl.
  
  Args:
      num_nodes: number of nodes in a graph
      edges: list of (u, v) tuples
      node_feat (optional): a dict of numpy array as node features
      edge_feat (optional): a dict of numpy array as edge features (should
                              have consistent order with edges)
  
  Examples:
  
      .. code-block:: python
  
          import numpy as np
          num_nodes = 5
          edges = [ (0, 1), (1, 2), (3, 4)]
          feature = np.random.randn(5, 100)
          edge_feature = np.random.randn(3, 100)
          graph = Graph(num_nodes=num_nodes,
                      edges=edges,
                      node_feat={
                          "feature": feature
                      },
                      edge_feat={
                          "edge_feature": edge_feature
                      })
class_docstr_tok: ["Implementation","of","graph","structure","in","pgl",".","This","is","a","simple","implementation","of","graph","structure","in","pgl",".","Args",":","num_nodes",":","number","of","nodes","in","a","graph","edges",":","list","of","(","u",",","v",")","tuples","node_feat","(","optional",")",":","a","dict","of","numpy","array","as","node","features","edge_feat","(","optional",")",":","a","dict","of","numpy","array","as","edge","features","(","should","have","consistent","order","with","edges",")","Examples",":","..","code-block",":",":","python","import","numpy","as","np","num_nodes","=","5","edges","=","[","(","0",",","1",")",",","(","1",",","2",")",",","(","3",",","4",")","]","feature","=","np.random.randn","(","5",",","100",")","edge_feature","=","np.random.randn","(","3",",","100",")","graph","=","Graph","(","num_nodes=num_nodes",",","edges=edges",",","node_feat=","{","``","feature","''",":","feature","}",",","edge_feat=","{","``","edge_feature","''",":","edge_feature","}",")"]
docstr: Find predecessor of given nodes.
  
  This function will return the predecessor of given nodes.
  
  Args:
      nodes: Return the predecessor of given nodes,
             if nodes is None, return predecessor for all nodes.
  
      return_eids: If True return nodes together with corresponding eid
  
  Return:
      Return a list of numpy.ndarray and each numpy.ndarray represent a list
      of predecessor ids for given nodes. If :code:`return_eids=True`, there will
      be an additional list of numpy.ndarray and each numpy.ndarray represent
      a list of eids that connected nodes to their predecessors.
  
  Example:
      .. code-block:: python
  
          import numpy as np
          num_nodes = 5
          edges = [ (0, 1), (1, 2), (3, 4)]
          graph = Graph(num_nodes=num_nodes,
                  edges=edges)
          pred, pred_eid = graph.predecessor(return_eids=True)
  
      This will give output.
  
      .. code-block:: python
  
          pred:
                [[],
                 [0],
                 [1],
                 [],
                 [3]]
  
          pred_eid:
                [[],
                 [0],
                 [1],
                 [],
                 [2]]
code: def predecessor(self, nodes=None, return_eids=False):
      """Find predecessor of given nodes.
  
      This function will return the predecessor of given nodes.
  
      Args:
          nodes: Return the predecessor of given nodes,
                 if nodes is None, return predecessor for all nodes.
  
          return_eids: If True return nodes together with corresponding eid
  
      Return:
          Return a list of numpy.ndarray and each numpy.ndarray represent a list
          of predecessor ids for given nodes. If :code:`return_eids=True`, there will
          be an additional list of numpy.ndarray and each numpy.ndarray represent
          a list of eids that connected nodes to their predecessors.
  
      Example:
          .. code-block:: python
  
              import numpy as np
              num_nodes = 5
              edges = [ (0, 1), (1, 2), (3, 4)]
              graph = Graph(num_nodes=num_nodes,
                      edges=edges)
              pred, pred_eid = graph.predecessor(return_eids=True)
  
          This will give output.
  
          .. code-block:: python
  
              pred:
                    [[],
                     [0],
                     [1],
                     [],
                     [3]]
  
              pred_eid:
                    [[],
                     [0],
                     [1],
                     [],
                     [2]]
  
      """
      if return_eids:
          return self.adj_dst_index.view_v(
              nodes
          ), self.adj_dst_index.view_eid(nodes)
      else:
          return self.adj_dst_index.view_v(nodes)
  
imports: import os
  import numpy
  import pickle
  import time
  import pgl.graph_kernel
  from collections import defaultdict
label_desc: Use image node_id 16 for calling the Graph obj's underlying member method code with example usage: obj.predecessor(nodes, return_eids) and returns: self,  self, self