Hi, Thanks James. Here is how I would do it -- groupCount is not needed.
g.idx(index_name)[[key:value]].both.loop(1){it.loops < depth}.count() Note: Be wary of this query. Make sure the branch factor of your graph is sufficiently small or the depth to which you are exploring is sufficiently small. With a large branch and depth, you can easily touch everything in your graph if your graph has "natural statistics." ( http://en.wikipedia.org/wiki/Scale-free_network ) Also, if you want to get fancy, what I like to do, is unroll my loops to increase performance. Given that the "while" construct of your loop step is simply "< depth," you can append an appropriate number of .both steps. traversal = g.idx(index_name)[[key:value]]; for(i in 0..depth) { traversal = traversal.both; } traversal.count(); Finally, 'both' is for undirected traversals. Use 'out' for outgoing traversals (follow the direction of the arrows) and 'in' for incoming traversals. https://github.com/tinkerpop/gremlin/wiki/Gremlin-Steps HTH, Marko. http://markorodriguez.com > > Xavier Shay wrote: >> >> "For all nodes in a particular index, how many other nodes are they >> connected to at depth X?" >> > > Marko will be able to improve upon this, but try something like this (this > is untested)... > > m = [:] > depth = 10 > index_name = "vertices" > index_key = "name" > index_nodes = g.idx(index_name).get(index_key,Neo4jTokens.QUERY_HEADER + > "*"). > index_nodes._().both.groupCount(m).loop(2){it.loops < depth} > m.size() > > - James > > > -- > View this message in context: > http://neo4j-community-discussions.438527.n3.nabble.com/Neo4j-Aggregate-queries-tp3317720p3317876.html > Sent from the Neo4j Community Discussions mailing list archive at Nabble.com. > _______________________________________________ > Neo4j mailing list > User@lists.neo4j.org > https://lists.neo4j.org/mailman/listinfo/user _______________________________________________ Neo4j mailing list User@lists.neo4j.org https://lists.neo4j.org/mailman/listinfo/user