Is there a way with py2neo to get all the connected nodes in a graph. All nodes that are connected by relationship?
Asked
Active
Viewed 656 times
2 Answers
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
-
the query looks simpler, however if you compare the profiles, the solution I provided is really more performant – Christophe Willemsen Nov 02 '15 at 22:14