西游记什么时候写的| 乳铁蛋白对宝宝有什么好处| 上海手表什么档次| 背胀是什么原因| 女生月经迟迟不来是什么原因| 头部紧绷感是什么原因| 鎏是什么意思| 北海龙王叫什么| 孕妇做梦梦到蛇是什么意思| 扔枕头有什么忌讳吗| 梦见儿子小时候是什么意思| 肾上腺彩超是检查什么| 陈皮是什么皮| 士官是什么级别| 柳下惠姓什么| 克罗心是什么牌子| 不负众望什么意思| 0什么意思| 低血糖什么症状有哪些| 怎么吃都不胖是什么原因| 什么叫外阴白斑| va是什么意思| 胆汁是什么| 甘油是什么油| 肺部真菌感染吃什么药| 口苦吃什么好| 乳头痒用什么药| 今年什么生肖| 才下眉头却上心头是什么意思| 辅酶是什么| 39属什么| 皂矾是什么| 急性上呼吸道感染是什么引起的| 经期吃凉的东西有什么影响| 丝芙兰是什么品牌| 痰带血丝是什么原因| 三头六臂是什么意思| 妇科假丝酵母菌是什么病| 捞人什么意思| 黑白蛇是什么蛇| 学架子鼓有什么好处| 做梦梦见很多蛇是什么意思| 身上起红疙瘩是什么| 83年猪是什么命| 谷丙转氨酶偏高吃什么药| 打蛋器什么牌子好| 为什么月经迟迟不来又没怀孕| 尿肌酐是什么| 白凉粉是什么做的| 乌龟为什么喜欢叠罗汉| 今年养殖什么最挣钱| 高血压能喝什么饮料| oct是什么意思| 荟字五行属什么| 今天股票为什么大跌| 尿偏红色是什么原因| 丝瓜有什么好处| 什么食物是发物| 为什么男生喜欢女生的脚| 躺枪是什么意思| 公元400年是什么朝代| 脉弱是什么原因导致的| 凌晨十二点是什么时辰| 九五至尊是什么生肖| 炸鱼是什么意思| 女性下面流水什么原因| 似是而非是什么意思| 乳头变大是什么原因| 爱妃是什么意思| 什么是编外人员| 什么是本命年| 鱼在鱼缸底部不动为什么| 吃什么最补脑| 血塞通治什么病| 为什么肚子老是胀气| 睡觉一直做梦是什么原因| 2t是什么意思| 女人排卵期是什么时候| 脓包疮用什么药| 硬卧代硬座是什么意思| 水晶是什么| 吉数是什么生肖| 附睾炎是什么原因引起的| 88属什么生肖| 阴沉木是什么木头| 排卵期同房后要注意什么| 口干舌燥口苦是什么原因引起的| 吃什么补肺养肺比较好| 惊讶表情是什么意思| 坤沙酒是什么意思| 低压高什么原因导致的| 贫血的人吃什么好| vivi是什么意思| 8朵玫瑰花代表什么意思| 绘本是什么意思| 前庭是什么意思| 囟门是什么意思| 南枝是什么意思| 大蒜泡酒治什么病| 蜻蜓为什么点水| 铁路12306什么时候放票| 胃热是什么原因引起的| 龟头是什么意思| 痛风可以吃什么肉类和蔬菜| 真菌感染用什么药好| 流产后吃什么水果好| 膝盖发软无力是什么原因| 长江学者是什么级别| 211985是什么意思| 空腹吃西红柿有什么危害| aojo眼镜什么档次| 贾宝玉的玉是什么来历| 日出东方下一句是什么| 绿萝叶子发黄是什么原因| 猪横利是什么| 6.12是什么星座| 飧泄是什么意思| 松针泡水喝有什么功效| 背包客是什么意思| 血小板分布宽度是什么意思| 什么白云| 老年性脑改变是什么意思| 莫言是什么意思| 做包皮手术挂什么科| 狮子座女和什么座最配| 为什么会胰岛素抵抗| 什么生火| 肺炎是什么症状| 甲醛是什么东西| 每天坚持跑步有什么好处| 牛肉饺子配什么菜好吃| 1987年五行属什么| 1985是什么年| 一个米一个更念什么| 尿管痒是什么原因| 哺乳期能吃什么水果| 三五行属什么| 鸟来家里预示什么| 红细胞压积什么意思| 血常规查什么| 过氧化氢阳性是什么意思| 僵尸车是什么意思| 切尔斯什么意思| 黑海为什么叫黑海| 孕妇刚生完孩子吃什么好| 走马观花是什么生肖| 推举是什么意思| 床头上面挂什么画好| 翩跹是什么意思| 梦见做被子什么意思| 梅毒是什么| 预谋是什么意思| 阿斯利康是什么药| 白玉是什么玉| 太监和宫女对食是什么意思| 膝盖痛吃什么| 前任是什么意思| 什么是瞬时速度| 异食癖是什么意思| 异性是什么意思| 什么球会自己长大| 脚有点浮肿是什么原因| 头晕应该挂什么科| 孬种是什么意思| 勾心斗角是什么意思| 乳房痛是什么原因| 腺样体增生是什么意思| 晚上十一点半是什么时辰| 令堂什么意思| 弥漫是什么意思| 泡蛇酒用什么药材最好| 排卵日有什么症状| 金匮肾气丸治什么病| ards是什么病的简称| 胃不舒服想吐是什么原因| 慢性胃炎有什么症状| 倒着走路有什么好处| 成人受到惊吓吃什么药| 螃蟹是什么季节吃的| 处女座男生喜欢什么样的女生| 喝酒后头晕是什么原因| 白玫瑰适合送什么人| 豁出去了什么意思| 微波炉不热是什么原因| 淋巴细胞偏高说明什么问题| 犀利的眼神是什么意思| 雷锋原名叫什么| 梦到自己结婚什么意思| 筹钱是什么意思| 梅雨季节是什么意思| 浑身乏力什么病的前兆| 龙日冲狗要忌讳什么| 喜欢放屁是什么原因| 淋巴细胞升高说明什么| 中央候补委员是什么级别| 星星是什么| 小二是什么意思| 脖子淋巴结肿大是什么原因| 大腿两侧疼痛什么原因| 血糖高适合喝什么茶| 跌打损伤用什么药好得快| 豆芽不能和什么一起吃| 羟丁酸脱氢酶高是什么原因| 护照补办需要什么材料| 211属于什么大学| 慕字五行属什么| 什么情况下会感染hpv病毒| 孕妇血糖高对胎儿有什么影响| 吃什么补血最好最快| 肝实质回声不均匀是什么意思| 1893年属什么生肖| 麻薯是什么| 东北属于什么气候| 秘书是干什么的| 胎动什么时候出现| 经常耳鸣是为什么| 百香果有什么功效与作用| pbs是什么| 益气是什么意思| 春节为什么要放鞭炮| 高密度脂蛋白低是什么原因| 拔腋毛有什么危害| 米老鼠叫什么名字| 嘴边长痘痘是什么原因| 微信为什么加不了好友| 咖啡什么牌子的好| 什么东西有脚却不能走路| 来源朋友验证消息是什么意思| 新疆以前叫什么| 弱智的人有什么表现| 磷偏低是什么原因| fpu是什么意思| 流鼻涕咳嗽吃什么药| 痛苦的反义词是什么| 男人有美人尖代表什么| 雅五行属什么| 晚睡早起是什么原因| 胸痛一阵一阵的痛什么原因| 办身份证穿什么颜色衣服| 梦见爸爸去世预兆什么| 苁蓉有什么功效| 孕妇梦见狗是什么意思| 化险为夷的夷什么意思| 盐水泡脚有什么好处| sandisk是什么牌子| 二氧化钛是什么东西| 做健身教练有什么要求| 放的偏旁是什么| 未可以加什么偏旁| 腹泻什么意思| 白露是什么意思| 牙龈上火是什么原因引起的| 生殖细胞瘤是什么病| 带状疱疹后遗神经痛挂什么科| 腺肌症是什么原因引起的| 北京的简称是什么| 泄身是什么意思| 胃酸吃什么| 月经不正常去医院检查什么项目| 拔罐有什么用| 头晕是什么症状引起的| 男人嘴小代表什么意思| 动物蛋白是什么| 心慌什么原因引起的| 百度Jump to content

扎克伯格至暗时刻曾改变世界 今成“全民公敌”扎克伯格脸书剑桥

From Wikipedia, the free encyclopedia
Johnson's algorithm
ClassAll-pairs shortest path problem (for weighted graphs)
Data structureGraph
Worst-case performance
百度 今天,来自世界的人们汇聚这里,品尝美食,追寻千年丝路文化。

Johnson's algorithm is a way to find the shortest paths between all pairs of vertices in an edge-weighted directed graph. It allows some of the edge weights to be negative numbers, but no negative-weight cycles may exist. It works by using the Bellman–Ford algorithm to compute a transformation of the input graph that removes all negative weights, allowing Dijkstra's algorithm to be used on the transformed graph.[1][2] It is named after Donald B. Johnson, who first published the technique in 1977.[3]

A similar reweighting technique is also used in a version of the successive shortest paths algorithm for the minimum cost flow problem due to Edmonds and Karp,[4] as well as in Suurballe's algorithm for finding two disjoint paths of minimum total length between the same two vertices in a graph with non-negative edge weights.[5]

Algorithm description

[edit]

Johnson's algorithm consists of the following steps:[1][2]

  1. First, a new node q is added to the graph, connected by zero-weight edges to each of the other nodes.
  2. Second, the Bellman–Ford algorithm is used, starting from the new vertex q, to find for each vertex v the minimum weight h(v) of a path from q to v. If this step detects a negative cycle, the algorithm is terminated.
  3. Next the edges of the original graph are reweighted using the values computed by the Bellman–Ford algorithm: an edge from u to v, having length ??, is given the new length w(u,v) + h(u) ? h(v).
  4. Finally, q is removed, and Dijkstra's algorithm is used to find the shortest paths from each node s to every other vertex in the reweighted graph. The distance in the original graph is then computed for each distance D(u, v), by adding h(v) ? h(u) to the distance returned by Dijkstra's algorithm.

Example

[edit]

The first three stages of Johnson's algorithm are depicted in the illustration below.

The graph on the left of the illustration has two negative edges, but no negative cycles. The center graph shows the new vertex q, a shortest path tree as computed by the Bellman–Ford algorithm with q as starting vertex, and the values h(v) computed at each other node as the length of the shortest path from q to that node. Note that these values are all non-positive, because q has a length-zero edge to each vertex and the shortest path can be no longer than that edge. On the right is shown the reweighted graph, formed by replacing each edge weight ?? by w(u,v) + h(u) ? h(v). In this reweighted graph, all edge weights are non-negative, but the shortest path between any two nodes uses the same sequence of edges as the shortest path between the same two nodes in the original graph. The algorithm concludes by applying Dijkstra's algorithm to each of the four starting nodes in the reweighted graph.

Correctness

[edit]

In the reweighted graph, all paths between a pair s and t of nodes have the same quantity h(s) ? h(t) added to them. The previous statement can be proven as follows: Let p be an ?? path. Its weight W in the reweighted graph is given by the following expression:

Every is cancelled by in the previous bracketed expression; therefore, we are left with the following expression for W:

The bracketed expression is the weight of p in the original weighting.

Since the reweighting adds the same amount to the weight of every ?? path, a path is a shortest path in the original weighting if and only if it is a shortest path after reweighting. The weight of edges that belong to a shortest path from q to any node is zero, and therefore the lengths of the shortest paths from q to every node become zero in the reweighted graph; however, they still remain shortest paths. Therefore, there can be no negative edges: if edge uv had a negative weight after the reweighting, then the zero-length path from q to u together with this edge would form a negative-length path from q to v, contradicting the fact that all vertices have zero distance from q. The non-existence of negative edges ensures the optimality of the paths found by Dijkstra's algorithm. The distances in the original graph may be calculated from the distances calculated by Dijkstra's algorithm in the reweighted graph by reversing the reweighting transformation.[1]

Analysis

[edit]

The time complexity of this algorithm, using Fibonacci heaps in the implementation of Dijkstra's algorithm, is : the algorithm uses time for the Bellman–Ford stage of the algorithm, and for each of the instantiations of Dijkstra's algorithm. Thus, when the graph is sparse, the total time can be faster than the Floyd–Warshall algorithm, which solves the same problem in time .[1]

References

[edit]
  1. ^ a b c d Cormen, Thomas H.; Leiserson, Charles E.; Rivest, Ronald L.; Stein, Clifford (2001), Introduction to Algorithms, MIT Press and McGraw-Hill, ISBN 978-0-262-03293-3. Section 25.3, "Johnson's algorithm for sparse graphs", pp. 636–640.
  2. ^ a b Black, Paul E. (2004), "Johnson's Algorithm", Dictionary of Algorithms and Data Structures, National Institute of Standards and Technology.
  3. ^ Johnson, Donald B. (1977), "Efficient algorithms for shortest paths in sparse networks", Journal of the ACM, 24 (1): 1–13, doi:10.1145/321992.321993, S2CID 207678246.
  4. ^ Edmonds, J.; Karp, Richard M. (1972), "Theoretical Improvements in Algorithmic Efficiency for Network Flow Problems", Journal of the ACM, 19 (2): 248–264, doi:10.1145/321694.321699.
  5. ^ Suurballe, J. W. (1974), "Disjoint paths in a network", Networks, 14 (2): 125–145, doi:10.1002/net.3230040204.
[edit]
高血脂吃什么食物最好 幽闭恐惧症是什么 什么水果含糖量低 哈密瓜为什么叫哈密瓜 温居是什么意思
身份证号码的数字代表什么意义 孕妇梦见狗是什么意思 梦到捡菌子是什么意思 吃荔枝有什么好处 左肾钙化灶什么意思
有缘人什么意思 黑色的屎是什么原因 腰椎穿刺是检查什么的 窝沟封闭是什么 睡觉时胳膊和手发麻是什么原因
白虎女是什么意思 绘本是什么意思 古天乐属什么生肖 左撇子是什么意思 啵啵是什么意思
发烧拉稀是什么原因0297y7.com 破军星是什么意思hcv8jop9ns4r.cn 质数是什么hcv8jop6ns2r.cn 什么的礼物hcv9jop2ns8r.cn maga是什么意思hcv9jop3ns0r.cn
83年猪是什么命hcv8jop1ns1r.cn 肺热吃什么药hcv8jop4ns3r.cn 脸上脂溢性皮炎用什么药hcv8jop3ns1r.cn 丑小鸭告诉我们一个什么道理hcv8jop4ns1r.cn 什么人适合学玄学hcv9jop5ns2r.cn
mrsa是什么细菌cj623037.com 眼角疼是什么原因hcv7jop6ns8r.cn 角化型脚气用什么药膏520myf.com 黑色素缺失吃什么补充最快hcv9jop5ns3r.cn ng是什么单位hcv9jop4ns4r.cn
八嘎呀路是什么意思hcv8jop4ns5r.cn 马拉色菌毛囊炎用什么药治疗最好hcv9jop5ns3r.cn 凶神宜忌是什么意思hcv8jop4ns7r.cn 什么原因导致高血压hcv7jop6ns1r.cn 如何知道自己是什么星座hcv7jop6ns4r.cn
百度