Hi Alan,

Did you try the query I suggested in my previous email from December? I
think it might be what you are after.

As a recap, what I wrote is:

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".


Regards, Craig

On Thu, Feb 11, 2016 at 6:35 PM, Alan Robertson <[email protected]> wrote:

> No one has any suggestions on how to write a query like this?
>
> Do I just find all possible paths and sort on length of path?
>
>
>
> On 12/23/2015 11:18 AM, Alan Robertson 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.
>
>
>
> --
>
> 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.

Reply via email to