How To Get Min-Cost Between twopoints in graph
(Dijkstra’s algorithm)
Now See This Graph :
which is just like asubway map .
Now Question is :
how to calculate fromA to (B,C,D,E,F,G,H,I,J) min cost ?
Now Let's go through Dijkstra's algorithm.
I will start follow these steps :
Step 1:
Take point from (A,B,C,D,E,F,G,H,I,J) .
Step 2:
find out the points it can reach ,save as reached-points
Step 3:
update the reached-points distance by the new dist if it is
smaller than the old value
ok , now take A, and we can see ,A can reach B,C,D
Now I take B. B Can Reach D,E. SoI need to update the value for D,E
As 4+3 < 8 . sothe value for D updated to 7.
Next ,Take C. C canreach D,F ,So I Need to update D,F values
Next ,Take D , D CanReach B,C,E,F,G , I Need to update them relatively .
But Can See ,D'svalue is 6 ,gather than B(4) and C(5) ,so no need update for B,C.
Next, Take E. whichCan Reach B,D,G,H
E(15)>B(4) ,E(15) > D(6), no updating.
E(15) + 6 >G(16),So no updating for G(16).
Next ,F .Can reach C,D,G,I
For C,D .
F(10) > D(6) ,F(10) > C(5) , so no updating .
Ok ,Next G. Whichcan reach D,E,F,H,I,J
G(15)>=E(15),G(15)>D(6),G(15) > F(10) .So No need update .now let's see how about H,I,J
G(15) + 3 < H(25)
G(15) + 5 <I(21)
J(30) is new added
so update them.
Next ,Take H. whichcan reach E,G,J
H(18) >E(15)=G(15) .No updating .
H(18) + 14 > J(30), also no updating .
Next ,Take I. CanReach F,G,J
I(20) >F(10),I(20)>G(15) , no updating
Let's see J
I(20) + 8 < J(30)
so update J(30)-> J(28)
Last ,Add J ,CanReach G,H,I
but J(28) >G(15),
J(28) > H(18),
J(28) > I(20)
so no updating .
分享到:
相关推荐
Neo4j,用户手册,涵盖所有集成的图算法及应用场景,非常适合图算法的学习和应用
DIJKSTRA算法解释Solution to the single-source shortest path problem in graph theory
jfgfgyutfuyjhfhykuhvjgyugkbujbhvtct
To understand a scene in depth not only involves locating/recognizing individual objects, but also requires to infer the relationships and interactions among them. However, sincethedistributionofreal-...
This program is to find the shortest path in the graph. Dijkstra Algorithm is used.
图机器学习峰会-1-2 Fairness and Explainability in Graph Learning
2019-MINCUT POOLING IN GRAPH NEURAL NETWORKS-网文-rrrr1
图机器学习峰会-1-2 Fairness and Explainability in Graph Learning.pdf
图优化slam学习常备,英文版,适合学习理论的广大slam学习者使用
opencv GrabCut -Interactive Foreground Extraction using Iterated Graph Cuts ,图像分割算法原文
Prolog-Dijkstra-Algorithm 使用Dijkstra算法的Prolog出租车调度程序应用程序。 该应用程序将尝试最佳调度出租车以接客。 这是通过使用Dijkstra的算法来找到最短路径来完成的,并为此提供了一种实现方法。 该...
DIJKSTRA is a MATLAB program which runs a simple demonstration of Dijkstra s algorithm for determining the minimum distance from one node in a graph to all other nodes. The program is mainly of ...
能够帮助你精确地取出数据。数据取点,数据图形绘制,图片图形取点,论文科研等必用。 1 首先file open image 2 点击xmin一步步设定xy最小值 3 选择取点 4 输出数据,并最终保存到一定的格式(xls等格式)
2019-ICML-YOU-Position-aware Graph Neural Networks-利用邻近锚点集,强化位置描述-rrrrr1
incubator-s2graph, Apache S2Graph镜像( 孵化) S2Graph S2Graph 是一个收费图表数据库,设计用来处理事务的事务处理。 its REST API 允许你用英镑 edge edge vertex vertex vertex vertex manner manner ma
relation-graph图谱移动端适配拖动修复代码
2019-Session-based Recommendation with Graph Neural Networks
Dijkstra s algorithm is an algorithm for finding the shortest paths between nodes in a graph
the-art in graph-based SSL algorithms, and the ability to implement them; (2) the ability to decide on the suitability of graph-based SSL methods for a problem; and (3) familiarity with different ...