0

Is there a way with py2neo to get all the connected nodes in a graph. All nodes that are connected by relationship?

Christophe Willemsen
  • 19,399
  • 2
  • 29
  • 36
Nicky Feller
  • 3,539
  • 9
  • 37
  • 54

2 Answers2

5

You can execute a Cypher query that will return you those :

res = graph.cypher.execute("MATCH (n) WHERE size((n)--()) > 0 RETURN n");
for r in res:
    print r
Christophe Willemsen
  • 19,399
  • 2
  • 29
  • 36
0

This Cypher query should be good enough:

MATCH (n)--() RETURN DISTINCT n
cybersam
  • 63,203
  • 6
  • 53
  • 76