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: Implement of random walk.
  
  This function get random walks path for given nodes and depth.
  
  Args:
      nodes: Walk starting from nodes
      max_depth: Max walking depth
  
  Return:
      A list of walks.
code: def random_walk(self, nodes, max_depth):
      """Implement of random walk.
  
      This function get random walks path for given nodes and depth.
  
      Args:
          nodes: Walk starting from nodes
          max_depth: Max walking depth
  
      Return:
          A list of walks.
      """
      walk = []
      # init
      for node in nodes:
          walk.append([node])
  
      cur_walk_ids = np.arange(0, len(nodes))
      cur_nodes = np.array(nodes)
      for l in range(max_depth):
          # select the walks not end
          outdegree = self.outdegree(cur_nodes)
          mask = outdegree != 0
          if np.any(mask):
              cur_walk_ids = cur_walk_ids[mask]
              cur_nodes = cur_nodes[mask]
              outdegree = outdegree[mask]
          else:
              # stop when all nodes have no successor
              break
          succ = self.successor(cur_nodes)
          sample_index = np.floor(
              np.random.rand(outdegree.shape[0]) * outdegree
          ).astype("int64")
  
          nxt_cur_nodes = []
          for s, ind, walk_id in zip(succ, sample_index, cur_walk_ids):
              walk[walk_id].append(s[ind])
              nxt_cur_nodes.append(s[ind])
          cur_nodes = np.array(nxt_cur_nodes)
      return walk
  
imports: import os
  import numpy
  import pickle
  import time
  import pgl.graph_kernel
  from collections import defaultdict
label_desc: Use image node_id 25 for calling the Graph obj's underlying member method code with example usage: obj.random_walk(nodes, max_depth) and returns: walk