algorithm - 算法有什么作用?isGood 的作用是什么?
问题描述
我知道这是 Dijkstra 的算法,但我无法弄清楚IsGood
.
输入:无向图,所有G=(V;E)
的边权重属于,一个顶点属于。le > 0
e
E
s
V
输出:对于每个 vertex v
,一个布尔值IsGood[v]
for each vertex v do
cost[v] = infinite // integer array indexed by elements of V
IsGood[v] = TRUE
end for
cost[s] = 0
MakeEmptyPriorityQueue(Q)
for each v belongs to V do
InsertPriorityQueue(Q; v; cost[v])
end for
while IsNotEmpty(Q) do
u = DeleteMin(Q)
for each edge e = (u; v) belongs to E, leaving u do
if cost[v] > cost[u] + le then
cost[v] = cost[u] + le
DecreaseKey(Q; v; cost[v])
IsGood[v] = IsGood[u]
else
IsGood[v] = FALSE
end if
end for
end while
解决方案
推荐阅读
- mysql - 处理一对多和多对一映射的问题
- javascript - setTimeout 设置为 0 时延迟约 100 毫秒
- c++ - 在Arduino中为二维指针数组赋值
- javascript - HTML:在同一页面上自动显示给定的输入
- cron - 如何在 yaml 文件的 cron 中使用 0/10?
- python - 如何逐个符号连接两个数组
- java - 使用 TextIO 运行程序时出现程序异常
- qt - 如何在 CMake 项目中使用 QtMqtt?
- r - 我正在尝试在 r 中绘制分段函数
- python - 尽管导入了所有包,Bert Tokenizer 仍无法正常工作。对此有新的语法更改吗?