最短路径查询返回空列表

Shortest path query returning empty list

我有一个包含 2851 个节点和 2887 个链接的网络。网络代表一个城市的铁路线

我一直在使用 NW 扩展来识别一些海龟之间的最短路径。

但是,对于某些查询,我返回的是一个空白列表,而不是合法的响应,或者返回 false(表示路由不存在)。

observer> ask turtle 3 [show nw:path-to turtle 13]
(node 3): [(link 3 4) (link 4 5) (link 5 6) (link 6 7) (link 7 8) (link 8 9) (link 9 10) (link 10 11) (link 11 12) (link 12 13)]

observer> ask turtle 3 [show nw:path-to turtle 2851]
(node 3): []

它按设计工作。 documentation of path primitives 表示:

If no path exist between the source and the target turtles, all primitives will report an empty list.

另一方面,distance primitives 将在不存在路径时报告 false。根据 documentation:

Finds the shortest path to the target turtle and reports the total distance for this path, or false if no path exists in the current context.

我承认这不是最一致的设计...