Introduction to main()
The sample main function creates the following graph with two connected components:
(0,10) (10,10) (20,10) (30,10)
(5,6) (10,6)
(25,5)
(5,4) (10,4) (20,4)
Figure 1: Graph g1
The shortest path between (0,0) and (10,6) is (0,0),(5,6),(10,6). There is no path between (0,0)
and (25,5), in which case ShortsetPath() does not print anything.
After the edge (0,0)-(5,6) is removed, the shortest path between (0,0) and (10,6) is
(0,0),(5,4),(10,4),(10,6).
(0,10) (10,10) (20,10) (30,10)
(5,6) (10,6)
(25,5)
(5,4) (10,4) (20,4)
Figure 2: Graph g1 after the edge (0,0)-(5,6) is removed
(0,0)
(0,0)
The output of ReachableVertices() for (0,0) is (0,10),(5,4),(5,6),(10,4),(10,6),(10,10). Notice that
the output is dependent on your implementation. The output of ReachableVertices() for (20,4)
is (20,10),(25,5),(30,10).
A sample output of ShowGraph(g1) is (0,0),(0,10) (0,0),(5,4) (0,10),(10,10) (0,10),(5,6)
(5,4),(10,4) (10,10), (10,6) (5, 6),(10,6) (10,4), (10,6) (20,4), (20,10) (20,10), (30,10)
(30,10),(25,5). Notice that the output is dependent on your implementation.
版权所有:留学生编程辅导网 2020 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。