I'm building a Maven dependency graph using Neo4J. One of the queries I need to support is finding all nodes that depend on a particular dependency. So if C depends on B and A, and B depends on A, findByDependency(A)
should return B and C. I implemented this using the following query, and it's working:
MATCH (v1)-[:DEPENDS_ON]->(v2)
WHERE EXISTS (v1.gav) AND v2.gav = "A"
RETURN DISTINCT v1.gav
However, in my example above, C also depends on B in addition to depending on A. I'd like the result set to be sorted such that B comes before C. I can do this in code, but is there a way to do it using Cypher?