The number of nodes / edges in a large graph through Gremlin?

What is the easiest and most efficient way to count the number of nodes / edges in a large graph through Gremlin? The best I have found is to use the V iterator:

gremlin> gVgather{it.size()} 

However, this is not a viable option for large graphs, for the documentation for V :

Vertex iterator for a graph. Use this to iterate over all the vertices in a graph. Use with caution on large charts if they are not used in conjunction with the search for key indexes.

+6
source share
1 answer

I think the preferred way to count all the vertices would be:

 gremlin> g = TinkerGraphFactory.createTinkerGraph() ==>tinkergraph[vertices:6 edges:6] gremlin> gVcount() ==>6 gremlin> gEcount() ==>6 

although, I think that on a very large chart, gV/E just breaks down, no matter what you do. On a very large graph, the best option for counting is to use a tool such as Faunus ( http://thinkaurelius.imtqy.com/faunus/ ) so that you can use the power from Hadoop to do the counts in parallel.

+5
source

Source: https://habr.com/ru/post/947736/


All Articles