Advertisement
Guest User

Untitled

a guest
Sep 1st, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. def dfs(rot):
  2.     stack = [];
  3.     stack.append(rot)
  4.     depth = 0;
  5.     node = rot
  6.  
  7.     while True:
  8.         print("Going to node %s, depth: %s" % (noder.index(node), depth))
  9.         if node.ratatosk:
  10.             return depth
  11.  
  12.         if node.barn != None:
  13.             for n in node.barn:
  14.                 stack.append(n)
  15.             #increase depth if node has no children, how to decrease?
  16.             depth+=1
  17.  
  18.         #change node to last in stack
  19.         next = stack.pop()
  20.  
  21.         node = next
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement