[Neo4j] Gremlin - how to flatten a tree, and sort

baldric kevin.versfeld at gmail.com
Fri Nov 4 17:25:13 CET 2011

I'm very new to much of this, and have a particularly ingrained relational
slant to my career, unfortunately.
I'm in the process of doing a proof of concept for a product, using neo4j,
and gremlin over REST (we're developing in c#) What I'm trying to do at the
moment is load a graph (representing a sort of flexible taxonomy), into a
flattened list. So, given a starting node, find all associated nodes across
a particular relationship type, no matter how far away. I will ultimately
need this in a list, and I want the list sorted by how far away each node is
(am I correct in referring to this as "hops"?)
Anyway, my best attempt at the unsorted query so far looks something like
this: (by the way, the "unique" part worries me a little....)

x = []; g.v(162).in('R_PartOf').aggregate(x).loop(2){true} >> -1; x.unique()

(Please try not to laugh too much! :) )

How would I alter this to ensure it is sorted by "distance" from starting

Thanks in advance!

View this message in context: http://neo4j-community-discussions.438527.n3.nabble.com/Gremlin-how-to-flatten-a-tree-and-sort-tp3480586p3480586.html
Sent from the Neo4j Community Discussions mailing list archive at Nabble.com.

More information about the User mailing list