发布时间 : 星期日 文章图遍历的演示报告及源代码更新完毕开始阅读
计算机软件技术基础课程设计 图的遍历的演示 龚陈继 eq \\o\\ac(○,B) eq \\o\\ac(○,C) eq \\o\\ac(○,D) eq \\o\\ac(○,E) eq \\o\\ac(○,F) eq \\o\\ac(○,G)
eq \\o\\ac(○,H) 选择操作1,分别进行以下操作:
Please input the number of G.vexnum (EG. G.vexnum=10): 8 Please input the number of G.edgenum (EG. G.edgenum=4): 9 Please input the number of IncInfo (0 for none): 0 Please intput 8 values of Vexs8(less 3 characters): A B C D E F G H
Please input 9 Edges orderly(interval by space): F G E H D H C G C F B E B D A C A B
2) 选择操作3,输出图的信息如下: This graph has 8 Vexs: A B C D E F G H
This graph has 9 Edges: A-B A-C B-D B-E C-F C-G D-H E-H F-G
3)选择操作4,输入遍历起点,如A(也可以输入B,C……) *****The result of DFSTraverse***** The Node list of DFSTraverse: A C G F B E H D
The Egde collection of DFSTraverse: A-B B-D D-H H-E A-C C-F F-G
Press any key to disply the DFSForest…
Page 13 of 18
计算机软件技术基础课程设计 图的遍历的演示 龚陈继
The BFSForest of BFSTraverse: The 1th tree: A B
D H E C F G
4)选择操作5,输入遍历起点,如A(也可以输入B,C……) *****The result of BFSTraverse***** The Node list of DFSTraverse: A B C D E F G H
The Egde collection of DFSTraverse: A-B B-D D-H B-E A-C C-F C-G
Press any key to disply the BFSForest… The BFSForest of BFSTraverse: The 1th tree: A
B D H E C F G
5) 选择操作7,输入以下信息: Please input the start nod: A Please input the end nod: H
Please input the node you don't want to pass: D All the paths form A to H and don’t pass D are: A->B->E->H
3、选择操作8销毁图,好继续下一个测试。
4、遍历一个非连通的无向图,如遍历以下这个非连通无向图:
eq \\o\\ac(○,A) eq \\o\\ac(○,C) eq \\o\\ac(○,D)
eq \\o\\ac(○,B) eq \\o\\ac(○,G) eq \\o\\ac(○,E) eq \\o\\ac(○,F) eq \\o\\ac(○,H)
eq \\o\\ac(○,I) 1)选择操作1,分别进行以下操作:
Please input the number of G.vexnum (EG. G.vexnum=10): 9 Please input the number of G.edgenum (EG. G.edgenum=4): 7 Please input the number of IncInfo (0 for none): 0
Page 14 of 18
计算机软件技术基础课程设计 图的遍历的演示 龚陈继
Please intput 9 values of Vexs8(less 3 characters): A B C D E F G H I
Please input 7 Edges orderly(interval by space): F I D H D F C G C E A B
2)选择操作3,输出图的信息如下: This graph has 9 Vexs: A B C D E F G H I
This graph has 7 Edges: A-B
C-E C-G D-F D-H E-G F-I
3)选择操作4,输入遍历起点,如A(也可以输入B,C……) *****The result of DFSTraverse***** The Node list of DFSTraverse: A B C G E D H F I
The Egde collection of DFSTraverse: A-B C-E E-G D-F F-I D-H
Press any key to disply the DFSForest… The BFSForest of BFSTraverse: The 1th tree: A B
The 2th tree: C
E G The 3th tree: D
F I
Page 15 of 18
计算机软件技术基础课程设计 图的遍历的演示 龚陈继
H
4) 选择操作5,输入遍历起点,如A(也可以输入B,C……) *****The result of BFSTraverse***** The Node list of DFSTraverse: A B C E G D F H I
The Egde collection of DFSTraverse: A-B C-E C-G D-F F-I D-H
Press any key to disply the BFSForest… The BFSForest of BFSTraverse: The 1th tree: A
B
The 2th tree: C
E G
The 3th tree: D
F I H
5) 选择操作7,输入以下信息: Please input the start nod: C Please input the end nod: E
Please input the node you don't want to pass: G All the paths form C to E and don’t pass G are: C->E 七、附录
源程序文件名清单:
GTraverse.cpp //主程序 GTraverse.exe //可执行文件 GTraverse.OBJ //目标源文件
1.txt //存有连通图信息的文本文档 2.txt //存有非连通图信息的文本文档 八、心得体会
这道题的完成,花了我两个通宵和几个白天时间,因为我在设计这道题的时候,老是要追求完美,本来第一天就完全可以把它的基本遍历功能完成。但觉得那么做意义不大,所以就逐步地增加了许多功能。把本来只能遍历连通图的功能上,改进为可以遍历非连通图,接着再改造为可以输出边集,后来又增加了打印生成树的功能,最后还增加了文件的保存和读取,路径的遍历。最难得是,把原来用C语言编写的程序改为用C++语言编写,虽然编写C++语言水平有限,但这个程序只是用到C++那些比较基础和简单的知识,所以对我来说,困雾还不是很大。
通过这道设计题,使我更深刻的理解数据结构及其重要作用,对数据结构有了一个新的认识,深刻的认识到数据结构对于我们学习计算机的重要性和其深远但是意义.同时,通过这次课程设计,也加强我的动手能力和思维能犛,可以将自己所学的知识用于实践,这不仅对自己是一次锻炼机会,而且让自己有一种成就感和自豪感耬觉得自己终于可以做出一点有用的
Page 16 of 18