Hi, I have the following attached graph where I have persons who traveled to some cities.
What I want to find out is, for a given city, for instance Toronto, "the ones who traveled there, also traveled to these other cities" (in the attached graph are Tokyo (by Adriano) and Paris (by Peter)). To retrieve this information, I did the following code: Collection<Node> allNodes = new ArrayList<Node>(); Node toronto = db.getNodeById(torontoId); // First I get Toronto node and its relationships to know who traveled there Iterable<Relationship> relationships = toronto.getRelationships(Relationships.TRAVELED_TO, Direction.INCOMING); for (Relationship relationship : relationships) { Node[] nodes = relationship.getNodes(); // For each relationship found, I all nodes that somehow is related to this relationship for (Node node : nodes) { Collection<Node> citiesNode = node.traverse(Order.DEPTH_FIRST, StopEvaluator.DEPTH_ONE, ReturnableEvaluator.ALL_BUT_START_NODE, Relationships.TRAVELED_TO, Direction.OUTGOING).getAllNodes(); // And finally I traverse the graph to find to find from theses nodes where the other people traveled to allNodes.addAll(citiesNode); } } Well, with this I can get the results I wanted, however, it seemed to me that what I did was too complicated :) . So, my question is: "is there any way to do this traversal in a more straightforward manner?". Thanks in advance. -- Adriano Almeida
<<attachment: graph.png>>
_______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user