class_docstr: Class representing a general ImageNet-style hierarchy.
class_docstr_tok: ["Class","representing","a","general","ImageNet-style","hierarchy","."]
docstr: Find all nodes accessible from a set of given nodes.
  
  Args:
      nodes (list) : List of WordNet IDs for relevant nodes
      direction ("up"/"down"): Traversal direction
      depth (int): Maximum depth to traverse (from nodes)
  
  Returns:
      Set of nodes reachable within the desired depth, in the
      desired direction.
docstr_tok: ["Find","all","nodes","accessible","from","a","set","of","given","nodes",".","Args",":","nodes","(","list",")",":","List","of","WordNet","IDs","for","relevant","nodes","direction","(","``","up","''","\/","''","down","''",")",":","Traversal","direction","depth","(","int",")",":","Maximum","depth","to","traverse","(","from","nodes",")","Returns",":","Set","of","nodes","reachable","within","the","desired","depth",",","in","the","desired","direction","."]
code: def traverse(self, nodes, direction="down", depth=100):
      """
      Find all nodes accessible from a set of given nodes.
  
      Args:
          nodes (list) : List of WordNet IDs for relevant nodes
          direction ("up"/"down"): Traversal direction
          depth (int): Maximum depth to traverse (from nodes)
  
      Returns:
          Set of nodes reachable within the desired depth, in the
          desired direction.
      """
  
      if not nodes or depth == 0:
          return nodes
  
      todo = []
      for n in nodes:
          if direction == "down":
              todo.extend(self.graph.successors(n))
          else:
              todo.extend(self.graph.predecessors(n))
      return nodes + self.traverse(
          todo, direction=direction, depth=depth - 1
      )
  
imports: import sys, os
  import json
  import numpy
  import pandas
  import urllib
  from collections import OrderedDict, Counter
  import operator
  import networkx
  from ..datasets import DATASETS
label_desc: Use image node_id 7 for calling the ClassHierarchy obj's underlying member method code with example usage: obj.traverse(nodes, direction, depth) and returns: unknown, nodes