class_docstr: Efficient basic implementation of nx `Graph' â€“ Undirected graphs with self loops
class_docstr_tok: ["Efficient","basic","implementation","of","nx","`","Graph","'","\u00e2\u20ac","\u201c","Undirected","graphs","with","self","loops"]
docstr: Returns a truncated random walk.
  
  path_length: Length of the random walk.
  alpha: probability of restarts.
  start: the start node of the random walk.
code: def random_walk(
      self, path_length, alpha=0, rand=random.Random(), start=None
  ):
      """Returns a truncated random walk.
  
      path_length: Length of the random walk.
      alpha: probability of restarts.
      start: the start node of the random walk.
      """
      G = self
      if start:
          path = [start]
      else:
          # Sampling is uniform w.r.t V, and not w.r.t E
          path = [rand.choice(list(G.keys()))]
  
      while len(path) < path_length:
          cur = path[-1]
          if len(G[cur]) > 0:
              if rand.random() >= alpha:
                  path.append(rand.choice(G[cur]))
              else:
                  path.append(path[0])
          else:
              break
      return [str(node) for node in path]
  
imports: import logging
  import sys
  from io import open
  from os import path
  from time import time
  from glob import glob
  from six.moves import range, zip, zip_longest
  from six import iterkeys
  from collections import defaultdict, Iterable
  import random
  from random import shuffle
  from itertools import product, permutations
  from scipy.io import loadmat
  from scipy.sparse import issparse
label_desc: Use image node_id 14 for calling the Graph obj's underlying member method code with example usage: obj.random_walk(path_length, alpha, rand, start) and returns: unknown