[英]Find shortest paths through predefined set of vertices and edges in arangodb
I need to find shortest paths which should pass through several nodes and edges.我需要找到应该通过几个节点和边的最短路径。 Few details:
几个细节:
Is there any way to find paths like this using arangodb?有没有办法使用arangodb找到这样的路径? I've tried K_SHORTEST_PATHS but it is too slow for some cases.
我试过 K_SHORTEST_PATHS 但在某些情况下它太慢了。
Without a data set, this is tricky to test.没有数据集,这很难测试。 Unfortunately,
K_SHORTEST_PATHS
is the only built-in way to add "weight" to edges, unless you build something yourself.不幸的是,
K_SHORTEST_PATHS
是向边缘添加“权重”的唯一内置方法,除非您自己构建一些东西。 Also, both SHORTEST_PATH
methods do not implement PRUNE
, which is the best way to speed graph traversal.此外,两种
SHORTEST_PATH
方法都没有实现PRUNE
,这是加速图遍历的最佳方式。
My suggestion would be to use a directed graph method ( FOR v,e,p IN 1..9 INBOUND x...
), implementing both PRUNE
and FILTER
clauses to reduce the number of hops, and something like COLLECT path = p AGGREGATE weight = SUM(e.weight)
to calculate weight.我的建议是使用有向图方法(
FOR v,e,p IN 1..9 INBOUND x...
),同时实施PRUNE
和FILTER
子句以减少跳数,以及类似COLLECT path = p AGGREGATE weight = SUM(e.weight)
计算重量。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.