无向图的邻接表表示及遍历实验报告电子版_第1页
无向图的邻接表表示及遍历实验报告电子版_第2页
无向图的邻接表表示及遍历实验报告电子版_第3页
无向图的邻接表表示及遍历实验报告电子版_第4页
无向图的邻接表表示及遍历实验报告电子版_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

promote the extension of strictly administering the party grass-roots, but also the educational practice of the mass line of the party and three-three special education results achieved further inherited and expanded. To realize two a learning education is a necessary solution to the present problems of party construction. Strengthen problem consciousness and insisted on problem-oriented, is full of strictly administering the party since the partys 18 a distinctive feature, a successful experience. Secretary Wang noted that some party members still have political awareness, lack of political responsibility issues, party awareness and consciousness of the problem belief does not really believe, slim does not actually fix problems, outspoken, and jump on the assessment of the partys policies, and so on. Bi Lifu Secretary pointed out that a quarter of the economic situation is very serious, there is pressure on environment, seasonal factors and other objective reasons, but mainly subjective problem, is the problem of party members and cadres. Some depressed, negative slack, not responsible, . Double six, one, and two took the lead, build energy burst, Hongshan district, economic prosperity, eco-livable, civilized and harmonious island. It certainly can not be separated from the whole area 646 grass-roots party organizations and 14,146 members of broad participation and support. Through the two study and education, so that every cell of the party health, every organization is strong, so that all members of the vanguard and exemplary role, all the fighting bastion role of grass-roots party organizations into full play so that we can cross the Rapids, overcome all difficulties and the smooth realization of the Thirteen-Five goal. Second, basic learning, focus on learning education must understand the learning content and learning styles Foundation learning these four words are important information inside is very large, capture profound work truth in life. For example, I often say that the good Carpenter NAO Carpenter, why do some carpenters made furniture to have everybody likes it, Carpenter we are not willing to look for him? are apparently two people high and low technology, dig into the deep is firmer when both of his apprentices are not solid, there is no good that way. Luban art of story primary school are learn had, first after six mark test practice conduct, and practice cultivation, and practice perseverance, and practice patience, then with seven days seven night mill axe theory armed, and unity action, seriously learning XI General Secretary on reform development stable, and Interior diplomatic defense, and rule party ruling army of important thought, seriously learning to XI comrade for General Secretary of Central ruling acting political new concept new thought new strategy, seriously learning XI General Secretary study in Inner Mongolia important speech spirit, Guide party members and a deep understanding of a series of important speeches rich connotation and core ideas, which began so thoroughly Marxist positions福州大学数计学院数据结构上机实验报告专业:应用数学学号姓名班级实验名称图的实验实验内容无向图的邻接表表示及遍历实验目的和要求掌握图的邻接表表示方法及实现技术掌握在图的邻接表表示方式下的图的遍历操作问题描述和主要步骤【实验内容】从键盘输入无向网络G的顶点个数v、边的个数e。建立由v个顶点、e条边构成的无向图G,采用邻接表表示。V个顶点的值由键盘输入,元素类型为字符型,e条边的信息亦由键盘输入 调用图的深度优先搜索遍历图并输出相应的遍历序列代码:#include stdafx.h#include #include #define MAX 20 /无向图最大顶点数typedef struct nodeint adjvex; /顶点序号struct node *next; /指向下一条弧的顶点*pointer;typedef structchar data; /顶点名称pointer first; /头指针headtype;typedef structheadtype adlistMAX;int n; /顶点数int e; /边数lkgraph;typedef struct treechar data; /结点名称struct tree *lchild; /存放第一个孩子struct tree *rchild; /存放兄弟*BTree;typedef structint *base;int *top;SqStack; /用于简单路径算法,最大长度为MAXbool visitMAX; /遍历中判断是否被访问int t_num; /非连通图生成子树BTree tMAX;bool flag=false; /判断是否存在简单路径void creategraph(lkgraph *g)/建立无向图的邻接表pointer p;int i,j,e=0;char c; /吸收回车printf(无向图邻接表的建立:n);printf( 顶点位置序号从0开始n);printf( 顶点名称用一个字符表示n);s1: printf( 请输入无向图的顶点数(小于等于20):n);scanf(%d,&i);if(i20) goto s1; /顶点数目输入不符合要求g-n=i;for(i=0;in;i+) /初始化c=getchar();printf(请输入顶点名称:n);scanf(%c,&g-adlisti.data);g-adlisti.first=NULL;printf(请输入一条边的两个顶点,用“,”隔开(当输入的第一个数为-1时,停止输入):n);scanf(%d,%d,&i,&j);while(i!=-1)e+;p=(pointer)malloc(sizeof(struct node);p-adjvex=j;p-next=g-adlisti.first;g-adlisti.first=p;p=(pointer)malloc(sizeof(struct node);p-adjvex=i;p-next=g-adlistj.first;g-adlistj.first=p;printf(请输入一条边的两个顶点,用“,”隔开(当输入的第一个数为-1时,停止输入):n);scanf(%d,%d,&i,&j);g-e=e;void show(lkgraph *g)/邻接表输出pointer p;printf(邻接表输出:n);for(int i=0;in;i+)printf(%c: ,g-adlisti.data);p=g-adlisti.first;while(p!=NULL)printf(%5d,p-adjvex);p=p-next;printf(n);void DFS(lkgraph *g,int v,BTree q)/从顶点v出发,递归地深度优先遍历gvisitv=true;BTree q1,l;q1=(BTree)malloc(sizeof(struct tree);q1-lchild=NULL;q1-rchild=NULL;printf(%5c,g-adlistv.data);q-data=g-adlistv.data;pointer p=g-adlistv.first;for(int w=0;p!=NULL;p=p-next)w=p-adjvex;if(!visitw)DFS(g,w,q1);l=q;if(l-lchild=NULL)l-lchild=q1;elsel=l-lchild;while(l-rchild!=NULL)l=l-rchild;l-rchild=q1;q1=(BTree)malloc(sizeof(struct tree);q1-lchild=NULL;q1-rchild=NULL;void DFSTraverse(lkgraph *g)printf(图的深度优先遍历:n);printf(请输入起始点序号(0%d):n,(g-n-1);int m,i;scanf(%d,&m);for(int v=0;vn;v+)visitv=false; /初始化if(!visitm)t0=(BTree)malloc(sizeof(struct tree);t0-lchild=NULL;t0-rchild=NULL;DFS(g,m,t0);printf(n);t_num=1;for(v=0,i=1;vn;v+)if(!visitv)ti=(BTree)malloc(sizeof(struct tree);ti-lchild=NULL;ti-rchild=NULL;DFS(g,v,ti);t_num+;i+;printf(n);BTree CreateBiTree()/将森林转化为二叉树BTree T,p,q;T=t0;p=T;for(int i=1;irchild=q;p=p-rchild;return T;void preorder(BTree l)/先序遍历if(l!=NULL)printf(%5c,l-data);preorder(l-lchild);preorder(l-rchild);void pasorder(BTree l)/后序遍历if(l!=NULL)pasorder(l-lchild);pasorder(l-rchild);printf(%5c,l-data); SqStack& InitStack(SqStack &s)/构造空栈s.base=(int*)malloc(MAX*sizeof(int);s.top=s.base;return s;void lujing(lkgraph *g,int a,int b,SqStack &s)int w,*i;pointer p;visita=true;*s.top=a;s.top+;i=s.top;if(a=b) /找到简单路径,输出flag=true;while(i!=s.base)i-;printf(%5d,*i); printf(n); p=g-adlista.first;while(p!=NULL)w=p-adjvex;if(!visitw)lujing(g,w,b,s);p=p-next;visita=false;s.top-;void Menu()printf(*n);printf(1建立无向图n);printf(2指定起始点,深度优先遍历n);printf( 先序遍历深度优先生成树n);printf( 后序遍历深度优先生成树n);printf(3求两点简单路径n);printf(0退出n);printf(*n);void main()lkgraph *g;SqStack s;BTree T;s=InitStack(s);int x;Menu();scanf(%d,&x);while(x!=0)if(x=1)g=(lkgraph*)malloc(sizeof(lkgraph);creategraph(g);show(g);else if(x=2)DFSTraverse(g);T=CreateBiTree();printf(n深度优先生成树的先序遍历为:n);preorder(T);printf(n深度优先生成树的后序遍历为:n);pasorder(T);printf(n);else if(x=3)printf(请输入起始点和终点位置,以“,”隔开:n);int a,b;scanf(%d,%d,&a,&b);for(int i=0;in;i+)visiti=false;lujing(g,a,b,s);if(flag=false)printf(不存在简单路径!n);elseprintf(输入错误n);Menu();scanf(%d,&x);实验结果(截图表示)研究与探讨通过这次实验对无向图的邻接表表示和深度优先遍历有了更深的了解,实验中还存在一些问题,需要多做实验加强。涉及重大决策事项、重要人事任免、重大项目安排和大额度资金使用等,具有决策、行政执法、行政许可、部门管理等决策、审批、自由裁量、事务管理决定权的领导岗位。To sum up, is divided into 9 main parts: 1. with regard to persisting and developing socialism with Chinese characteristics. 18 since the XIOn more than one occasion, General Secretary of the historical origin and development process of socialism with Chinese characteristics, the road of socialism with Chinese characteristics, System Info, system, uphold and develop the understanding of socialism with Chinese characteristics is determined to have been profoundly expounded, further strengthened the party and the people adhere to and develop the confidence and determination of the socialism with Chinese characteristics. XI General Secretarys speech in this regard include the peoples yearning for a better life, that is our goal, closely focus on the development of socialism with Chinese characteristics study and publicize the spirit of party 18, the unwaveringly adhere to the development of socialism with Chinese characteristics, the persistence and good use of Mao Ze-Dongs thought of soul. 2. with regard to the Chinese dream of realizing the great rejuvenation of the Chinese nation. 18 closing soon, the new Central collective leadership when they visited the exhibition of the road to recovery, XI, General Secretary of the solemn declaration the great rejuvenation of the Chinese nation, the greatest dream of the Chinese nation in modern times. Zhihou, on more than one occasion, General Secretary expounded the scientific connotation of Chinese dream, realize the Chinese dream must take the road, carry forward the spirit and cohesion of Chinese forces, gradually formed the China dream, a strategic thought. And practice with the Chinese dream, reflects the history of the new session of the CPC Central Committee, and conforms to the development trend and the people hope, embodies the greatest common divisor and the consensus of Chinese people at home and abroad, inspiring all peoples forging ahead in unity, the spirit of unswervingly follow the road of socialism with Chinese characteristics flags and high melody. This aspects XI General Secretary of speech main including achieved

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论