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: Sample predecessor of given nodes.
  
  Args:
      nodes: Given nodes whose predecessor will be sampled.
  
      max_degree: The max sampled predecessor for each nodes.
  
      return_eids: Whether to return the corresponding eids.
  
  Return:
  
      Return a list of numpy.ndarray and each numpy.ndarray represent a list
      of sampled 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.
code: def sample_predecessor(
      self, nodes, max_degree, return_eids=False, shuffle=False
  ):
      """Sample predecessor of given nodes.
  
      Args:
          nodes: Given nodes whose predecessor will be sampled.
  
          max_degree: The max sampled predecessor for each nodes.
  
          return_eids: Whether to return the corresponding eids.
  
      Return:
  
          Return a list of numpy.ndarray and each numpy.ndarray represent a list
          of sampled 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.
      """
      node_pred = self.predecessor(nodes, return_eids=return_eids)
      if return_eids:
          node_pred, node_pred_eid = node_pred
  
      if nodes is None:
          nodes = self.nodes
  
      node_pred = node_pred.tolist()
  
      if return_eids:
          node_pred_eid = node_pred_eid.tolist()
  
      if return_eids:
          return graph_kernel.sample_subset_with_eid(
              node_pred, node_pred_eid, max_degree, shuffle
          )
      else:
          return graph_kernel.sample_subset(
              node_pred, max_degree, shuffle
          )
  
imports: import os
  import numpy
  import pickle
  import time
  import pgl.graph_kernel
  from collections import defaultdict
label_desc: Use image node_id 17 for calling the Graph obj's underlying member method code with example usage: obj.sample_predecessor(nodes, max_degree, return_eids, shuffle) and returns: graph_kernel, graph_kernel