The Graph:
Facts:
A cyclist starts at the far left of the image above. They read the plan to know where to go. A plan is composed of legs. Legs are composed of landmarks. A cyclist completes a leg by traveling from the beginning landmark to the ending landmark. A plan is complete when a cyclist travels all legs in the plan. A plan may have an infinite number of legs. Additionally, two plans may be contiguous if the ending landmark of the first plan is the same as the beginning landmark of the second plan. The number of contiguous plans is also infinite.
The Question:
If a cyclist starts at the first leg of an arbitrarily selected plan, then how many plans can a cyclist follow to travel a specified maximum distance.
I'm having trouble coming up with a cypher match pattern that depicts a variable length path comprised of contiguous legs (legs are contiguous, technically, not plans).
I've done something like:
match (:Plan)-[:DEPICTS]->(start:Leg)
with start
match path = (start)-[:ENDS*..]->(:Landmark)<-[:BEGINS*..]-(:Leg)
return path
I have also tried the following, which returns all of the components that have this pattern instead of only returning the components with (start:Leg) as the root.
match (:Plan)-[:DEPICTS]->(start:Leg)
with start
match path = (:Leg)-[:ENDS*..]->(:Landmark)<-[:BEGINS*..]-(:Leg)
return path
This does not return a full path, instead it stops at the first pattern match.
- Neo4j 4.1.1 Enterprise
- Neo4j.Driver-4.2