Database Reference
In-Depth Information
a given Node")
public class GraphTraversal extends ServerPlugin {
@Name("graph_traversal")
@org.neo4j.server.plugins.Description("Traversing
Graphs from a given Node")
@PluginTarget(GraphDatabaseService.class)
public Iterable<Path> executeTraversal(@Source
GraphDatabaseService graphDb,
@org.neo4j.server.plugins.Description("Value of
'Name' property, considered as RootNode for searching
")
@Parameter(name = "name") String name) {
return startTraversing(graphDb, name);
}
public enum RelTypes implements RelationshipType {
ACTED_IN, DIRECTED
}
private List<Path>
startTraversing(GraphDatabaseService graphDb, String
name) {
List<Path> allPaths = new ArrayList<Path>();
// Start a Transaction
try (Transaction tx = graphDb.beginTx()) {
// get the Traversal Descriptor from instance
of Graph DB
TraversalDescription trvDesc =
graphDb.traversalDescription();
// Defining Traversals needs to use Depth First
Approach
trvDesc = trvDesc.depthFirst();
// Instructing to exclude the Start Position
and include all
// other Nodes while Traversing
trvDesc =
trvDesc.evaluator(Evaluators.excludeStartPosition());
// Defines the depth of the Traversals. Higher the
Search WWH ::




Custom Search