SHARE
TWEET

Untitled

a guest Nov 12th, 2019 62 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def dfs(root, final_state_number, h=None, h_type=None):
  2.     stack = collections.deque()
  3.     stack.appendleft(root)
  4.     visited = []
  5.     steps = 0
  6.  
  7.     while len(stack) != 0:
  8.         curr_state = stack.popleft()
  9.         steps += 1
  10.  
  11.         if curr_state.is_final(final_state_number):
  12.             return curr_state.path, curr_state.profit + curr_state.capacity, steps
  13.  
  14.         visited.append(curr_state)
  15.  
  16.         children = curr_state.get_children()
  17.         for state in list(reversed(children)):
  18.             if state not in visited:
  19.                 stack.appendleft(state)
  20.  
  21.     return False
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top