Number of nodes/edges in a large graph via Gremlin?

这一生的挚爱 提交于 2019-12-08 16:05:20

问题


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

gremlin> g.V.gather{it.size()}

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

The vertex iterator for the graph. Utilize this to iterate through all the vertices in the graph. Use with care on large graphs unless used in combination with a key index lookup.


回答1:


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

gremlin> g = TinkerGraphFactory.createTinkerGraph()
==>tinkergraph[vertices:6 edges:6]
gremlin> g.V.count()
==>6
gremlin> g.E.count()
==>6

though, I think that on a very large graph g.V/E just breaks down no matter what you do. On a very large graph the best option for doing a count is to use a tool like Faunus(http://thinkaurelius.github.io/faunus/) so that you can leverage the power of Hadoop to do the counts in parallel.



来源:https://stackoverflow.com/questions/17214959/number-of-nodes-edges-in-a-large-graph-via-gremlin

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!