See discussion at
http://stackoverflow.com/questions/12540701/making-a-neo4j-cypher-query-stop-when-a-condition-is-true
Cheers,
/peter neubauer
Neo4j 1.8.RC1 "Vindeln Vy" -
http://blog.neo4j.org/2012/09/neo4j-18rc1-really-careful-ftw.html
G: neubauer.peter
S: peter.neubauer
P: +46 704 106975
L:
http://www.linkedin.com/in/neubauer
T: @peterneubauer
Wanna learn something new? Come to @graphconnect.
On Fri, Sep 21, 2012 at 8:47 PM, daniel bob <
coda...@gmail.com> wrote:
> Hello all,
>
> I have a graph of java classes. Each class represents a node, and contains
> the namespace and name of the class. There is an edge type called USES which
> I am trying to use to determine a simple anti pattern. I want to find
> instances of the following: a class in namespace A uses a class in namespace
> B, which then uses another etc, until one of the classes is in Class A
> again. For the case where there are 3 classes, Class A, Class B and Class C
> where Class A is in namespace A, Class B is in namespace B and class C is in
> namespace A I'm using the query:
>
> START inside1 = node(*)
> match inside1 -[:USES]-> outside1 -[:USES]-> outside2 -[:USES]-> inside2
> where inside1.namespace <> outside1.namespace and inside2.namespace =
> inside1.namespace
> return inside1
>
> As far as I can tell so far, this does work. The problem is I need it for
> longer paths. So far I have attempted with this:
>
> START inside1 = node(*)
> match inside1 -[:USES]-> outside1 -[:USES*] -> outside2 -[:USES]-> inside2
> where inside1.namespace <> outside1.namespace and outside2.namespace <>
> inside1.namespace and inside2.namespace = inside1.namespace
> return
inside1.name,
outside1.name,
inside2.name
>
> The problem here is that I do not want to traverse through any nodes which
> are in the namespace of inside1 and inside2 between outside2 and inside2. So
> my question is, how can i specify "stop when you hit a node whose namespace
> is equal to the namespace of inside1"?
>
> Thanks.
>
> --
>
>