無向圖的鄰接表表示及遍歷實驗報告電子版_第1頁
無向圖的鄰接表表示及遍歷實驗報告電子版_第2頁
無向圖的鄰接表表示及遍歷實驗報告電子版_第3頁
無向圖的鄰接表表示及遍歷實驗報告電子版_第4頁
無向圖的鄰接表表示及遍歷實驗報告電子版_第5頁
已閱讀5頁,還剩2頁未讀, 繼續(xù)免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

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福州大學數計學院數據結構上機實驗報告專業(yè):應用數學學號姓名班級實驗名稱圖的實驗實驗內容無向圖的鄰接表表示及遍歷實驗目的和要求掌握圖的鄰接表表示方法及實現技術掌握在圖的鄰接表表示方式下的圖的遍歷操作問題描述和主要步驟【實驗內容】從鍵盤輸入無向網絡G的頂點個數v、邊的個數e。建立由v個頂點、e條邊構成的無向圖G,采用鄰接表表示。V個頂點的值由鍵盤輸入,元素類型為字符型,e條邊的信息亦由鍵盤輸入 調用圖的深度優(yōu)先搜索遍歷圖并輸出相應的遍歷序列代碼:#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出發(fā),遞歸地深度優(yōu)先遍歷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(圖的深度優(yōu)先遍歷: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指定起始點,深度優(yōu)先遍歷n);printf( 先序遍歷深度優(yōu)先生成樹n);printf( 后序遍歷深度優(yōu)先生成樹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深度優(yōu)先生成樹的先序遍歷為:n);preorder(T);printf(n深度優(yōu)先生成樹的后序遍歷為: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);實驗結果(截圖表示)研究與探討通過這次實驗對無向圖的鄰接表表示和深度優(yōu)先遍歷有了更深的了解,實驗中還存在一些問題,需要多做實驗加強。涉及重大決策事項、重要人事任免、重大項目安排和大額度資金使用等,具有決策、行政執(zhí)法、行政許可、部門管理等決策、審批、自由裁量、事務管理決定權的領導崗位。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. 未經權益所有人同意不得將文件中的內容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論