Database Reference
In-Depth Information
trvDesc.traverse(getStartNode());
// Let us get the Paths from Traverser and start
iterating or moving
// along the Path
for (Path path : traverser) {
//Print ID of Start Node
System.out.println("Start Node ID = "+
path.startNode().getId());
//Print number of relationships between Start and
End //Node
System.out.println("No of Relationships = " +
path.length());
//Print ID of End Node
System.out.println("End Node ID = " +
path.endNode().getId());
}
}
}
private Node getStartNode() {
try (Transaction tx = graphDb.beginTx()) {
ExecutionEngine engine = new
ExecutionEngine(graphDb,StringLogger.SYSTEM);
ExecutionResult result = engine
.execute("match (n)-[r]->() where n.Name=\"Sylvester
Stallone\" return n as RootNode");
Iterator<Object> iter = result.columnAs("RootNode");
return (Node) iter.next();
}
}
}
Now let's understand the preceding code and discuss the important sections of the code.
The code defines three methods:
Search WWH ::




Custom Search