Try this:

MATCH (a:Person{name:1})-->(b)-->(c)-->(d)
with collect(DISTINCT b) as nodesDist1, collect(DISTINCT c) as
nodesDist2,collect(DISTINCT
d) as nodesDist3
RETURN nodesDist1,
                filter(n in nodesDist2 WHERE NOT n in nodesDist1) as
nodesDist2,
                filter(n in nodesDist3 WHERE NOT n in nodesDist1 OR n in
nodesDist2) as nodesDist3


On Wed, Apr 13, 2016 at 8:52 AM, Kamilos <k19me...@gmail.com> wrote:

> hello,
> I'm trying to compute the k-hop using cypher.
>
> The idea is the following :
>  The nodes at distance 1 from start node should be marked "NodesDist1",
>  then, nodes at distance 2 should be names "NodesDist2" but they should
> not be the same as "NodeDistance1".
>  Again, the nodes at Distance 3, should be different than the in
> NodesDist1 and NodesDistance2. See Image for more clarifications.
>
>
> <https://lh3.googleusercontent.com/-8Add_nPhxMs/Vw3q9iMmuwI/AAAAAAAAAHc/x4vINs9bVa8aS1omuWxUbIn7uYwe3WH7gCLcB/s1600/untitled.png>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> Just getting the nodes from the outgoing edges is not a good solution
> because the nodes from the outgoing edges may already been seen in, for
> instance, NodesDist1.
>
> So I need I a way to filter them.
>
>
> This is what i got from the moment. However the "where filter" is not
> working, apparatently i cannot do that ?
>
>
> MATCH (a:Person{name:1})-->b-->c
> with collect(DISTINCT(b.name)) as nodesDist1, collect(DISTINCT(c.name))
> as nodesDist2,
> where filter(x IN nodesDist2 WHERE not(x in nodesDist1)) as res return
> res");
>
>
> So I'm looking for a way to do this query in cypher.
>
> --
> 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 neo4j+unsubscr...@googlegroups.com.
> 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 neo4j+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to