title: How define a Traverse for neo4j with Python?
body: <p>I need to traverse a neo4j graph using Python27.</p>
  
  <p>From the manual I've seen that I can define a <strong>Traversal</strong> and include a <strong>Evaluator</strong> and I got something similar to that.</p>
  
  <pre><code>def my_evaluator(path):
      if (path.end['type'] == 'STOP') or (path.end['type'] == 'BUS_STOP'):
          return Evaluation.EXCLUDE_AND_CONTINUE
      else:
          return Evaluation.INCLUDE_AND_CONTINUE
  
  def get_passengers_with_bus_stop(db, start_node):
      nodes = []
  
      traverser = db.traversal()\
          .relationships('STOPS_AT', INCOMING)\
          .relationships('HAS_BEEN', OUTGOING)\
          .evaluator(my_evaluator)\
          .traverse(start_node)
  
      # Name
      for n in traverser.nodes.iterator():
          nodes.append(n['name'])
  
      return nodes
  </code></pre>
  
  <p>But from the list of nodes returned I want to exclude the first node and sometimes stop at some Deepth.</p>
  
  <p>How can I do that with the <strong>Traversals</strong> that defines de neo4j manual?</p>
  
  <p>At sometimes I've found a presentation that explains another way to define <strong>Traversals</strong> but this don't runs properly, I receive and error from Python. Do I need something else installed?</p>
  
  <pre><code>class Users(neo4j.Traversal): # Traversals ! queries in Neo4j
      types = [ neo4j.INCOMING.WORKS_AS,neo4j.OUTGOING.BELONGS_TO]
      order = neo4j.BREADTH_FIRST
      stop = neo4j.STOP_AT_END_OF_GRAPH
      returnable = neo4j.RETURN_ALL_BUT_START_NODE
  </code></pre>
  
  <p>How can I define a Traverse for neo4j with Python to:</p>
  
  <ul>
  <li>Exclude the first node</li>
  <li>Stop at some deepth</li>
  </ul>
  
  <p>Maybe I should use <strong>subtraversals</strong>? How can I define them?</p>
  
  <p>More specifically I want to define a <strong>Traversal</strong> over this graph to go from the node "I'm" here to node "-1" or node "+1" alone. The graph defines de direction of the relations and the names of them.</p>
  
  <p><img src="https://i.stack.imgur.com/Bjqk3.jpg" alt="enter image description here"></p>