0

When I query MATCH (n:label {Name_1: 'A'}) MATCH (n)--(p)--(q)--(r) RETURN n, p, q, r

enter image description here

But B receives connection from other nodes aswell, like

enter image description here

Here I want B to be given only when I query every node connected to B with a query like

MATCH (n:label {Name_1: 'A'}), (m:label {Name_1: 'F'}), (o:label {Name_1: 'E'})
MATCH (n)--(p)--(q)--(r)
RETURN n, m, o, p, q, r

Can we attain it?

Brakebein
  • 2,197
  • 1
  • 16
  • 21
Gram
  • 33
  • 3

1 Answers1

0

I'm not sure, if I understand you correctly: You just want a query that matches the graph in the second figure? Or am I missing something?

You can MATCH more complex patterns that are not just linear:

MATCH (n:label {Name_1: 'A'}), (m:label {Name_1: 'F'}), (o:label {Name_1: 'E'})
MATCH (n)--(p)--(q)--(r),
      (p)--(m),
      (p)--(o)
RETURN n, m, o, p, q, r

Or more compact:

MATCH (n:label {Name_1: 'A'})--(p)--(q)--(r),
      (p)--(m:label {Name_1: 'F'}),
      (p)--(o:label {Name_1: 'E'})
RETURN n, m, o, p, q, r
Brakebein
  • 2,197
  • 1
  • 16
  • 21