title: How to keep track of node depth in DFS without recursion(using a stack)?
body: <p>This is my code snippet for DFS with out recursion in python:</p>
  
  <pre><code> def DFS(graph,start,end):
  explored=[]
  queue=[[start]]
  
  if start == end:
      return "done"
  while queue:
      path=queue.pop()
      node=path[-1]
      if node not in explored:
          neighbours=graph[node]
  
          for neighbour in neighbours:
              new_path=list(path)
              new_path.append(neighbour.name)
              queue.append(new_path)
              if neighbour.name== end:
                  return new_path
          explored.append(node)
  return "no path"
  </code></pre>
  
  <p>This is how my node looks like:
      class edge:
      #def <strong>init</strong>():</p>
  
  <pre><code>def __init__(self,name,value,depth=0):
      self.name=name
      self.value=value
      self.depth=depth
  </code></pre>
  
  <p>How do I keep track of levels of each node as I've to implement depth limited search without recursion?</p>