辅导C程序、讲解C程序、辅导C报告
- 首页 >> C/C++编程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.