0

Given: 3 nodes labelled A, B, C

Graph: (A)-[1]-(B), (B)-[2]-(C), (A)-[2]-(C)

Desired: A query that returns nodes where relation name is not "2" starting from (A).

Tried:

Match (n:A)-[r]-(x) where type(r)<>"2" return n,r,x

AND

MATCH p=(n:A)--(y) WHERE ALL(z in relationships(p) WHERE type(z) <> "2" RETURN n,y

Though I get in the browser a graph that includes all relations from (A) including "2" - in this case (A)-[2]-(C)

Maybe just thinking wrong - how would I exclude a dedicated relation from the graph shown in the neo4j browser?

Balael
  • 401
  • 5
  • 18

1 Answers1

1

Not sure what is happening with your data or query, but if I created some test data

create (a:A {name: 'A'})-[:`1`]->(b:B {name: 'B'})
create (b)-[:`2`]->(c:C {name: 'C'} )
create (a)-[:`2`]->(c)
return *

I have a graph that looks like this...

enter image description here

Then if i query it with your first query

match (n:A)-[r]-(x) 
where type(r)<>"2" 
return n,r,x

Then neo4j only returns the A and B nodes that are joined by the relationship with type 1.

enter image description here

Is it possible there is some whitespace in your data somewhere in your query that is causing your query to not return the results you expect?

Dave Bennett
  • 10,996
  • 3
  • 30
  • 41