【发布时间】:2011-11-30 16:13:38
【问题描述】:
以下是我们教授给我们的算法总结。
第 3 步中提到的图中节点的父节点是什么? 我有点困惑,因为我认为这些节点只有邻居而没有父节点?
我的第二个问题是关于第 3 步,“在堆栈中提取第索引记录”。由于堆栈只允许您查看顶部,我不确定拾取第 index 条记录意味着什么?
Dijkstra 的最短路径:
Step 0: if s == d, stop.
Step 1: current node c= s, c.length = 0, stack.push (c, its length, and parent).
If u is the source s then no need for parent.
Step 2: min = 0, hop = infinite, index = 1
Step 3: pick up the index’th record in stack, say node u, its length u.length,
and its parent w.
Step 4: find a neighbor of u in the table of neighbors, say v, such that v is
not found in any item in stack and <u,v> +u.length< hop.
Step 5: if such a neighbor is found, hop=min=u.length + <u,v> and record_node = v
Step 6: go to step 4 until all the neighbors of u have been tried (all can be
found in stack).
Step 7: index ++, go to step 3 until all the nodes have been tried (found in
stack).
Step 8: c = record_node, c.length = min, stack_push(c, c.length, u). If c == d
stop the entire process and goes to step 9 for data collection,
otherwise go to step 2.
Step 9: (t, d.length, and t.parent) = (d, d.length, and d.parent) in stack,
keep searching on (t.parent, t.parent.length, t.parent.parent),
until t.parent = s.
【问题讨论】:
-
您是否尝试过与您的教授讨论这些问题?既然他给了你这个算法,他可能会解释得最清楚。
-
是的,我已经问过了。不幸的是,语言障碍会导致问题。我希望对算法有深刻理解的人能够识别他想要传达的内容。谢谢。
-
这太可怕了(我的意思是总结)。在其 Wikipedia 页面或一些类似来源上了解该算法,其中描述的并不那么密集。算法本身并不难掌握,有很好的解释。
标签: algorithm dijkstra shortest-path