Reputation: 732
The database has nodes which form a tree. Each node follows another with the predicate "precedes". I want to write a query that can read the entire tree given the start node.
I have tried Morphism, but the output makes no sense to me at all. Perhaps because of my lack of understand on what "Morphism" actually means ...
Any hints, or links to actual good examples would be appreciated
Upvotes: 1
Views: 244
Reputation: 732
As @Bruno pointed out in his answer, the equivalent of * in Gremlin is FollowRecursive().
var c1 = g.M().Both("precedes")
g.V("chain-1").FollowRecursive(c1).All()
One key thing here is the .Both part in the Morphism Query. It encodes that the direction of the predicate should be both In and Out. I am not sure how that maps to the Neo4j query pattern
Upvotes: 3
Reputation: 16375
In Neo4j you should do something like this:
MATCH p = (:Root)-[:precedes*]-()
RETURN p
Note that the *
specified after the relationship type will do a full search in the entire graph. It can cause memory issues.
Upvotes: 1