简体   繁体   中英

how to calculate average path length in neo4j

I have 1250000 nodes in neo4j, now I want to calculate the average path length among these nodes. Is there a effective way to do this? If i use: for x in nodes: for y in nodes: cal(x,y) I think it costs too much time. So I want a more efficient algorithm.Thanks!

好吧,我将复制该图(例如在Neo4j HA群集中),然后在每个节点上仅运行总x的一部分,以这种方式并行计算。

You can try to avoid computing the paths that you already computed in previous steps (somehow like you'd do in dynamic programming). For instance, lets say that you have the path x->y->z, than when computing x--->z path, you'd memorize the paths x->y and y->z so that you can use them later on.

If you use this approach you may hit memory limits, depending on your server configuration.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM