Pavel Vanchugov
Pavel Vanchugov

Reputation: 393

neo4j get nodes in order of connections

http://console.neo4j.org/r/z1iafh is it possible to return n.name in order so it would be CREATE (node_name); without adding new properties to nodes? I see that there is a sequence in which nodes in this test database are connected to each other, so i am interested is it possible to somehow het this sequence.

enter image description here

START n=node(*) MATCH (n)-[r:CREATE_NODE_COMMAND]->(m) RETURN n

Upvotes: 3

Views: 602

Answers (1)

Christophe Willemsen
Christophe Willemsen

Reputation: 20185

First you need to declare a path identifier, then add depth and lastly you can order by path length :

START n=node(*) MATCH p=(n)-[r:CREATE_NODE_COMMAND*..10]->(m)
ORDER BY length(p)
LIMIT 1
RETURN nodes(p)

Upvotes: 2

Related Questions