2
29,16,8,1
30,17,9,14
31,17,19,3
32,17,18,10
33,18,15,8
34,18,3,8
35,19,18,12
36,2,3,20
37,3,5,20
38,5,7,20
39,7,11,20
40,11,13,20
41,17,11,20
42,11,19,20
43,17,5,20
44,5,19,20
运行结果:
root@linux_ever:~/linux_ever/algorithm/graph_ch9# ls
case0 case1 graph.h testGraph testGraph.cpp
root@linux_ever:~/linux_ever/algorithm/graph_ch9# ./testGraph ./case0/topo.csv
Open file ./case0/topo.csv OK.
There are 8 lines in file ./case0/topo.csv.
******************************************************************
0-->1(边号:0,权重:1)-->2(边号:1,权重:2)-->3(边号:2,权重:1)-->NULL
2-->1(边号:3,权重:3)-->3(边号:5,权重:1)-->NULL
3-->1(边号:4,权重:1)-->2(边号:6,权重:1)-->0(边号:7,权重:1)-->NULL
******************************************************************
root@linux_ever:~/linux_ever/algorithm/graph_ch9# ./testGraph ./case1/topo.csv
Open file ./case1/topo.csv OK.
There are 45 lines in file ./case1/topo.csv.
******************************************************************
0-->13(边号:0,权重:15)-->8(边号:1,权重:17)-->19(边号:2,权重:1)-->4(边号:3,权重:8)-->NULL
1-->0(边号:4,权重:4)-->NULL
2-->9(边号:5,权重:19)-->15(边号:6,权重:8)-->3(边号:36,权重:20)-->NULL
3-->0(边号:7,权重:14)-->11(边号:8,权重:12)-->5(边号:37,权重:20)-->NULL
4-->1(边号:9,权重:15)-->5(边号:10,权重:17)-->NULL
5-->8(边号:11,权重:18)-->9(边号:12,权重:14)-->6(边号:13,权重:2)-->7(边号:38,权重:20)-->19(边号:44,权重:20)-->NULL
6-->17(边号:14,权重:4)-->NULL
7-->13(边号:15,权重:1)-->16(边号:16,权重:19)-->11(边号:39,权重:20)-->NULL
8-->6(边号:17,权重:1)-->12(边号:18,权重:17)-->NULL
9-->14(边号:19,权重:11)-->NULL
10-->12(边号:20,权重:1)-->NULL
11-->7(边号:21,权重:12)-->4(边号:22,权重:7)-->13(边号:40,权重:20)-->19(边号:42,权重:20)-->NULL
12-->14(边号:23,权重:5)-->NULL
13-->17(边号:24,权重:12)-->4(边号:25,权重:2)-->NULL
14-->19(边号:26,权重:9)-->NULL
15-->10(边号:27,权重:14)-->18(边号:28,权重:2)-->NULL
16-->8(边号:29,权重:1)-->NULL
17-->9(边号:30,权重:14)-->19(边号:31,权重:3)-->18(边号:32,权重:10)-->11(边号:41,权重:20)-->5(边号:43,权重:20)-->NULL
18-->15(边号:33,权重:8)-->3(边号:34,权重:8)-->NULL
19-->18(边号:35,权重:12)-->NULL
******************************************************************
输出结果的每一行的第一列表示各个顶点的标号。
比如:
0-->13(边号:0,权重:15)-->8(边号:1,权重:17)-->19(边号:2,权重:1)-->4(边号:3,权重:8)-->NULL
上面表示,顶点0到13的边的边号为0,权重为15。顶点0到顶点8的边的边号为1,权重为17。顶点0到顶点19的边的边号为2,权重为1。顶点0到顶点4的边的边号为3,权重为8。
|