Hi Alan,
Off the top of my head, a cypher query that should work for this would be:
MATCH p=(ruleset:Ruleset
{id:{id}})-[:basedon*0..]->(:Ruleset)-[:rulemember]->(rule:Rule {r:{name}})
RETURN rule, length(p) as len ORDER BY len ASC LIMIT 1
With params: id=<something to identify the starting point> and name="rule1".
The actual shortestPath() function will not work because it requires both
end nodes to be known. But for short paths, or small graphs, the above
approach should be fast enough.
Regards, Craig
On Wed, Dec 23, 2015 at 7:18 PM, Alan Robertson <[email protected]> wrote:
> I want to find the shortest path to any node which has a specific property.
>
> +-[:rulemember]->(r="rule1")
> /
>
> (ruleset1)-[:basedon]->(ruleset2)-[:basedon]->(ruleset3)-[:rulemember]->(r="rule1")
> \
> +-[:rulemember]->(r="rule1")
>
> The context is this:
> This is a set of rules, based on [:basedon] other sets of rules.
> The rulesets contain member rules [:rulemember].
> The rule closest to the starting point is the rule that is in effect.
>
> If I want to know which version of rule1 (the one with r="rule1") is in
> effect for ruleset1, then the answer would be the rule1 below the line. You
> get different answers if you give ruleset2 or ruleset3 as the starting
> point.
>
> If the graph looks like the one below and the starting point is ruleset1,
> then the answer should be the "rule1" above the starting line.
>
> +-[:rulemember]->(r="rule1")
> /
>
> (ruleset1)-[:basedon]->(ruleset2)-[:basedon]->(ruleset3)-[:rulemember]->(r="rule1")
>
>
>
> This is analogous to a question like "Where is the closest ATM?". I want
> the shortest path to a node with a particular property (i.e., that
> satisfies a particular predicate).
> ATM == Cash machine == Geldautomat and no doubt other names ;-)
>
>
> --
>
> Alan Robertson / CTO
> [email protected] / +1 303.947.7999
>
> Assimilation Systems Limited
> http://AssimilationSystems.com
>
> [image: Twitter] <https://twitter.com/ossalanr> [image: Linkedin]
> <https://www.linkedin.com/in/alanr> [image: skype]
> <https://htmlsig.com/skype?username=alanr_unix.sh>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Neo4j" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
>
--
You received this message because you are subscribed to the Google Groups
"Neo4j" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.