Gremlin query to find the count of a label for all the nodes

Viewed 2852

Sample query
The following query returns me the count of a label say "Asset " for a particular id (0) has >>>
g.V().hasId(0).repeat(out()).emit().hasLabel('Asset').count()

But I need to find the count for all the nodes that are present in the graph with a condition as above.

I am able to do it individually but my requirement is to get the count for all the nodes that has that label say 'Asset'.

So I am expecting some thing like

{ v[0]:2
      {v[1]:1}
           {v[2]:1}
}
where v[1] and v[2] has a node under them with a label say "Asset" respectively, making the overall count v[0] =2 .

1 Answers
Related