首页 > 解决方案 > Networkx Dijkstra Shortest Path 存在,但太长了 - 预先给我一个近似值的算法

问题描述

我正在用networkx计算最短路径。大多数时候工作正常,但有时节点是连接的,但通过网络中一个非常奇怪的远程连接。在这种情况下,算法会产生内存错误。我的问题是,如果有一种很好的方法可以预先检查节点之间的连接是否对最短路径的长度有意义,通过我定义的阈值。

标签: networkxshortest-path

解决方案


If you are interested in general solution you can modify Dijkstras algorithm and limit it to a maximum number of nodes or a maximum length and just abort, once that threshold is broken.

I don't know networkx so I don't know if this is available out of the box.


推荐阅读