gpt4 book ai didi

c++ - 在 Lemon 图形库中使用 Dijkstra 算法

转载 作者:太空宇宙 更新时间:2023-11-04 12:06:18 26 4
gpt4 key购买 nike

我对从 Lemon Graph Libraries (Lemon's Dijkstra's http://lemon.cs.elte.hu/pub/tutorial/a00009.html) 运行 Dijkstra 算法所需的一些参数有疑问。要运行该算法,可以编写类似 dijkstra(g, length).distMap(dist).run(s,t); 的代码,其中 g 是图,s 是起始节点,t 是目标节点。我的问题是什么是 lengthdist,它们是如何使用的。谢谢!

最佳答案

按照我的理解,它们都需要是映射,一个到边长(输入)一到顶点的距离(输出),

同时检查 lgf_demo.cc 和 dijkstra_test.cc并注意

Dijkstra& distMap ( DistMap & m ) [inline]

Sets the map that stores the distances of the nodes calculated by the algorithm. If you don't use this function before calling run() or init(), an instance will be allocated automatically. The destructor deallocates this automatically allocated map, of course.

Returns: (*this)


const DistMap& distMap ( ) const [inline]

Returns a const reference to the node map that stores the distances of the nodes calculated by the algorithm.

Precondition: Either run() or init() must be called before using this function.

这就是您的 Dijstra 输出。

关于c++ - 在 Lemon 图形库中使用 Dijkstra 算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11941415/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com