大數(shù)據(jù)結(jié)構(gòu)-實驗六-報告材料_第1頁
大數(shù)據(jù)結(jié)構(gòu)-實驗六-報告材料_第2頁
大數(shù)據(jù)結(jié)構(gòu)-實驗六-報告材料_第3頁
已閱讀5頁,還剩27頁未讀 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

實用文案實用文案標準文檔標準文檔實驗報告實驗六 圖的應用及其實現(xiàn)一、實驗目的進一步功固圖常用的存儲結(jié)構(gòu)。熟練掌握在圖的鄰接表實現(xiàn)圖的基本操作。AOVAOE二、實驗內(nèi)容一>.基礎題目:(本類題目屬于驗證性的,要求學生獨立完成)AOV然后對該圖拓撲排序,并輸出拓撲序列.試設計程序?qū)崿F(xiàn)上述AOV網(wǎng)的類型定義和基本操作,完成上述功能。[題目二]:從鍵盤上輸入AOEAOE操作,完成上述功能。測試數(shù)據(jù):教材圖7.29【題目五】連通OR不連通描述:給定一個無向圖,一共n個點,請編寫一個程序?qū)崿F(xiàn)兩種操作:Dxy從原圖中刪除連接x,y節(jié)點的邊。Qxy詢問x,y節(jié)點是否連通輸入第一行兩個數(shù)n,m(5<=n<=40000,1<=m<=100000)m行,每行一對整數(shù)xy(x,y<=n)x,y接下來一行一個整數(shù)q(q<=100000)以下q行每行一種操作,保證不會有非法刪除。輸出按詢問次序輸出所有Q操作的回答,連通的回答C,不連通的回答D樣例輸入331213235Q12D12Q12D32Q12樣例輸出CCD【題目六】 SortProblemAnascendingsortedsequenceofdistinctvaluesisoneinwhichsomeformofaless-thanoperatorisusedtoordertheelementsfromsmallesttolargest.Forexample,thesortedsequenceA,B,C,DimpliesthatA<B,B<CandC<D.inthisproblem,wewillgiveyouasetofrelationsoftheformA<Bandaskyoutodeterminewhetherasortedorderhasbeenspecifiedornot.【Input】Input consistsofmultipleprobleminstances. Each instancestartswith aline containing twopositiveintegersnandm. thefirstvalueindicatedthenumberof objectstosort, where2<=n<=26.Theobjectstobesortedwillbethefirstncharactersoftheuppercasealphabet.ThesecondvaluemindicatesthenumberofrelationsoftheformA<Bwhichwillbegiveninthisprobleminstance.1<=m<=100.Nextwillbemlines, eachcontainingonesuch relationconsistingofthree characters:anuppercaseletter,thecharacter"<"anda seconduppercaseletter.Noletterwillbeoutsidetherangeofthefirstnlettersofthealphabet.Valuesofn=m=0indicateendofinput.【Output】Foreachprobleminstance,outputconsistsofoneline.Thislineshouldbeoneofthefollowingthree:Sortedsequencedetermined:yyy…y.Sortedsequencecannotbedetermined.Inconsistencyfound.yyy…y isthesorted,ascendingsequence.SampleInput Sample Output46 Sortedsequencedetermined:ABCD.A<B Inconsistencyfound.A<C Sortedsequencecannotbedetermined.B<CC<DB<DA<B32A<BB<A262A<ZD<S00設計要求 :1、上機前,認真學習教材,熟練掌握AOV網(wǎng)、AOE網(wǎng)的構(gòu)造和拓撲排序算法。2、上機前,認真獨立地寫出本次程序清單,流程圖,該程序包括圖類型以及每一種操作的具體的函數(shù)定義和主函數(shù)。有關算法分別參閱講義和參考教材事例三、實驗步驟㈠、數(shù)據(jù)結(jié)構(gòu)與核心算法的設計描述#defineMAX_VERTEX_NUM20//變量聲明typedefstructArcNode//弧結(jié)點定義{intadjvex; //該弧所指向的頂點的位置structArcNode指向下一條弧的指針//InfoType*info;}ArcNode;typedefstructVNode//頂點結(jié)點定義{chardata; //頂點信息ArcNode*firstarc; //指向第一條依附該頂點的弧的指針}VNode,AdjList[MAX_VERTEX_NUM];typedefstruct//圖的定義{AdjListvertices;intvexnum,arcnum; //圖的當前頂點數(shù)和弧intkind; //圖的種類標志}ALGraph;ALGraphG; //定義圖變量boolvisited[MAX_VERTEX_NUM]; //訪問標志數(shù)intindegree[MAX_VERTEX_NUM]; 入度數(shù)組structStack棧類型定義{ints[21];inttop;};Stackstack;定義一個棧實用文案實用文案相關函數(shù)聲明:void CreateGraph(MGraph&G)//v)//深度優(yōu)先搜索遍歷圖voidBFSTraverse(GraphG,intv)//廣度優(yōu)先搜索遍歷圖intLocateVertices(ALGraphG,chara)//查找字符a在圖中的位置intFirstAdjVex(ALGraphG,intv)//查找圖中位置v的第一個鄰接點在圖中所在的位置intNextAdjVex(ALGraphG,intv,intw)//查找相對于圖中位置v的鄰接點w的下一鄰接點在圖中的位置voidDestroyGraph(ALGraph&G)//銷毀圖voidInitStack(Stack&stack)//初始化棧voidPushStack(Stack&stack,inti)//元素i入棧voidPopStack(Stack&stack,int&i)//棧頂元素出棧intStackEmpty(Stackstack)//判斷棧是否為空,若為空則返回1,否則返回0voidFindInDegree(ALGraphG,int*indegree)//求圖中各個頂點的入度,并相應的存入入度數(shù)組中indegree[]intTopologicalSort(ALGraphG)//對圖進行拓撲排序,并輸出相應的拓撲序列㈡、函數(shù)調(diào)用及主函數(shù)設計調(diào)用CreateGraph(G);主函數(shù)調(diào)用TopologicalSort(G)標準文檔

調(diào)用DestroyGraph(G)實用文案實用文案㈢程序調(diào)試及運行結(jié)果分析由于以前已經(jīng)做過了關于圖的一些算法設計,例如:圖的深度優(yōu)先遍歷,廣度優(yōu)先遍歷等,因此,這次試驗基本沒有什么錯誤。㈣實驗總結(jié)這次的實驗使得我對圖的定義及其更多的操作有了更深入的了數(shù)據(jù)結(jié)構(gòu)及算法實現(xiàn),圖的存儲結(jié)構(gòu)。這是我收獲最大的地方。四、主要算法流程圖及程序清單1、主要算法流程圖:查找相對于圖中位置v的鄰接點w的下一鄰接點在圖中的位置intNextAdjVex(ALGraphG,intv,intw)開始p=G.vertices[v].firstarc;開始p=G.vertices[v].firstarc;否實用文案實用文案否是是否開始利 用 鄰 接 表 存 儲 結(jié) 構(gòu) 構(gòu) 造 有 向 CreateGraph(ALGraph&G)開始

void輸入圖的頂點和弧的個數(shù)cin>>G.vexnum>>G.arcnum;輸入頂點值存入圖中i=1否結(jié)束標準文檔cin>>s; 實用文案實用文案開始開始求各定點入度FindInDegree(G,indegree);是查找圖中位置v的第一個鄰接點在圖中所在的位置intFirstAdjVex(ALGraphG,intv)開始開始G.vertices[v].firstarc=NULL是return-1;否returnG.vertices[v].firstarc->adjvex;對圖進行拓撲排序,并輸出相應的拓撲序列intTopologicalSort(ALGraphG)標準文檔實用文案實用文案標準文檔標準文檔是否否是2、程序清單題目一:#include<iostream.h>#include<stdlib.h>#defineMAX_VERTEX_NUM20typedefstructArcNode//弧結(jié)點定義{intadjvex; //該弧所指向的頂點的位置structArcNode*nextarc;//指向下一條弧的指針//InfoType*info;}ArcNode;typedefstructVNode//頂點結(jié)點定義{chardata; //頂點信息ArcNode*firstarc; //指向第一條依附該頂點的弧的指針}VNode,AdjList[MAX_VERTEX_NUM];typedefstruct//圖的定義{AdjListvertices;intvexnum,arcnum; //圖的當前頂點數(shù)和弧intkind; //圖的種類標志}ALGraph;ALGraphG; //定義圖變量boolvisited[MAX_VERTEX_NUM]; //訪問標志數(shù)intindegree[20]; //各結(jié)點入度數(shù)組structStack棧類型定義{ints[21];inttop;};Stackstack; //定義一個棧intLocateVertices(ALGraphG,chara)//查找字符a在圖中的位置{for(inti=0;i<G.vexnum;i++)if(G.vertices[i].data==a)returni;return-1;}void CreateGraph(ALGraph&G)//利用鄰接表存儲結(jié)構(gòu)構(gòu)造有向圖{inta,b;chars;ArcNode*p;cout<<endl<<"現(xiàn)在要構(gòu)造一個有向圖"<<endl;cout<<"請輸入頂點個數(shù)和圖中弧的個數(shù)"<<endl;cin>>G.vexnum>>G.arcnum;cout<<"請輸入各個頂點的值,頂點的值類型為字符類型"<<endl;for(inti=0;i<G.vexnum;i++){cin>>G.vertices[i].data;G.vertices[i].firstarc=NULL;}cout<<"請輸入圖中各個弧"<<endl<<"(每一個弧用其所依附的兩個頂點值表示,先輸入弧尾頂點值,再輸入弧頭頂點值)"<<endl;for(i=1;i<=G.arcnum;i++){cin>>s;a=LocateVertices(G,s);cin>>s;b=LocateVertices(G,s);p=newArcNode;if(!p)return;p->adjvex=b;p->nextarc=G.vertices[a].firstarc;G.vertices[a].firstarc=p;}}intFirstAdjVex(ALGraphG,intv)//查找圖中位置v的第一個鄰接點在圖中所在的位置{if(G.vertices[v].firstarc)returnG.vertices[v].firstarc->adjvex;return-1;}intNextAdjVex(ALGraphG,intv,intw)//查找相對于圖中位置v的鄰接點w的下一鄰接點在圖中的位置{ArcNode*p;p=G.vertices[v].firstarc;while(p->adjvex!=w)p=p->nextarc;if(p->nextarc)returnp->nextarc->adjvex;return-1;}voidDestroyGraph(ALGraph&G)//銷毀圖{ArcNode*p,*p1;for(inti=0;i<G.vexnum;i++){p=G.vertices[i].firstarc;if(p)p1=p->nextarc;while(p){deletep;p=p1;if(p1)p1=p1->nextarc;}}}voidInitStack(Stack&stack)//初始化棧{stack.top=0;}voidPushStack(Stack&stack,inti)//元素i入棧{stack.s[stack.top++]=i;}voidPopStack(Stack&stack,int&i)//棧頂元素出棧{i=stack.s[--stack.top];}intStackEmpty(Stackstack)//判斷棧是否為空,若為空則返回1,否則返回0{if(!stack.top)return1;return0;}voidFindInDegree(ALGraphG,int*indegree)//求圖中各個頂點的入度,并相應的存入入度數(shù)組中indegree[]{ArcNode*p;for(inti=0;i<G.vexnum;i++)indegree[i]=0;for(i=0;i<G.vexnum;i++){p=G.vertices[i].firstarc;while(p){indegree[p->adjvex]++;p=p->nextarc;}}}intTopologicalSort(ALGraphG)//對圖進行拓撲排序,并輸出相應的拓撲序列{intcount=0,w;FindInDegree(G,indegree);for(inti=0;i<G.vexnum;i++)if(!indegree[i])while(!StackEmpty(stack)){PopStack(stack,i);cout<<G.vertices[i].data<<"";count++;for(w=FirstAdjVex(G,i);w>=0;w=NextAdjVex(G,i,w))if(!(--indegree[w]))PushStack(stack,w);}if(count<G.vexnum)return-1;return1;}voidmain(){CreateGraph(G);cout<<endl<<"拓撲排序的結(jié)果如下:"<<endl;if(!TopologicalSort(G))cout<<"圖中存在有環(huán)"<<endl;cout<<endl;DestroyGraph(G);}題目二:#include<iostream.h>#include<stdlib.h>#defineMAX_VERTEX_NUM20typedefstructArcNode//弧結(jié)點定義{intadjvex; //該弧所指向的頂點的位置structArcNode指向下一條弧的指針intinfo;}ArcNode;typedefstructVNode//頂點結(jié)點定義{chardata; //頂點信息ArcNode*firstarc; //指向第一條依附該頂點的弧的指針}VNode,AdjList[MAX_VERTEX_NUM];typedefstruct//圖的定義{AdjListvertices;intvexnum,arcnum; //圖的當前頂點數(shù)和弧intkind; //圖的種類標志}ALGraph;ALGraphG; //定義圖變量boolvisited[MAX_VERTEX_NUM]; //訪問標志數(shù)intindegree[20]; //各結(jié)點入度數(shù)組intve[20]; //定義頂點最早開始時間存儲數(shù)組intvl[20]; //定義頂點最遲開始時間存儲數(shù)組structStack棧類型定義{ints[21];inttop;};Stackstack; //定義一個棧,用于拓撲排序時存儲入度為0的頂點Stackstack1; //存儲逆拓撲排序有序序列Stackstack2; //intLocateVertices(ALGraphG,chara)//查找字符a在圖中的位置{for(inti=0;i<G.vexnum;i++)if(G.vertices[i].data==a)returni;return-1;}void CreateGraph(ALGraph&G)//利用鄰接表存儲結(jié)構(gòu)構(gòu)造有向圖{inta,b;chars;ArcNode*p;cout<<endl<<"現(xiàn)在要構(gòu)造一個有向圖"<<endl;cout<<"請輸入頂點個數(shù)和圖中弧的個數(shù)"<<endl;cin>>G.vexnum>>G.arcnum;cout<<"請輸入各個頂點的值,頂點的值類型為字符類型"<<endl;for(inti=0;i<G.vexnum;i++){cin>>G.vertices[i].data;G.vertices[i].firstarc=NULL;}cout<<"請輸入圖中各個弧"<<endl<<"(每一個弧用其所依附的兩個頂點值表示,先輸入弧尾頂點值,再輸入弧頭頂點值)"<<endl;for(i=1;i<=G.arcnum;i++){cin>>s;a=LocateVertices(G,s);cin>>s;b=LocateVertices(G,s);p=newArcNode;if(!p)return;p->adjvex=b;"<<endl;cin>>p->info;p->nextarc=G.vertices[a].firstarc;G.vertices[a].firstarc=p;}}voidDestroyGraph(ALGraph&G)//銷毀圖{ArcNode*p,*p1;for(inti=0;i<G.vexnum;i++){p=G.vertices[i].firstarc;if(p)p1=p->nextarc;while(p){deletep;p=p1;if(p1)p1=p1->nextarc;}}}voidInitStack(Stack&stack)//初始化棧{stack.top=0;}voidPushStack(Stack&stack,inti)//元素i入棧{stack.s[stack.top++]=i;}voidPopStack(Stack&stack,int&i)//棧頂元素出棧{i=stack.s[--stack.top];}intStackEmpty(Stackstack)//判斷棧是否為空,若為空則返回1,否則返回0{if(!stack.top)return1;return0;}intGetTopStack(Stackstack)//獲得棧頂元素{returnstack.s[stack.top-1];}voidFindInDegree(ALGraphG,int*indegree)//求圖中各個頂點的入度,并相應的存入入度數(shù)組中indegree[]{ArcNode*p;for(inti=0;i<G.vexnum;i++)indegree[i]=0;for(i=0;i<G.vexnum;i++){p=G.vertices[i].firstarc;while(p){indegree[p->adjvex]++;p=p->nextarc;}}}intTopologicalSort(ALGraphG)//對圖進行拓撲排序,并輸出相應的拓撲序列{intcount=0;ArcNode*p;FindInDegree(G,indegree);InitStack(stack);InitStack(stack1);for(inti=0;i<G.vexnum;i++)ve[i]=0;for(i=0;i<G.vexnum;i++)if(!indegree[i])PushStack(stack,i);while(!StackEmpty(stack)){PopStack(stack,i);PushStack(stack1,i);count++;for(p=G.vertices[i].firstarc;p;p=p->nextarc){if(!(--indegree[p->adjvex]))PushStack(stack,p->adjvex);if(ve[i]+p->info>ve[p->adjvex])ve[p->adjvex]=ve[i]+p->info;}}if(count<G.vexnum)return-1;return1;}intCriticalPath(ALGraphG)//求關鍵活動,并輸出所有活動,關鍵活動用*標志,同時獲得關鍵路徑的逆序序列{chartag;intj,sum=0;ArcNode*p;InitStack(stack2);PushStack(stack2,0);if(TopologicalSort(G)==-1)return-1;for(inti=0;i<G.vexnum;i++)vl[i]=ve[G.vexnum-1];while(!StackEmpty(stack1))for(PopStack(stack1,j),p=G.vertices[j].firstarc;p;p=p->nextarc)if(vl[p->adjvex]-p->info<vl[j])vl[j]=vl[p->adjvex]-p->info;for(j=0;j<G.vexnum;j++)for(p=G.vertices[j].firstarc;p;p=p->nextarc){tag=(ve[j]==vl[p->adjvex]-p->info)?'*':'';cout<<G.vertices[j].data<<""<<G.vertices[p->adjvex].data<<" "<<vl[p->adjvex]-p->adjvex<<""<<tag<<endl;if(j==GetTopStack(stack2)&&tag=='*'){

"<<ve[j]<<"PushStack(stack2,p->adjvex);sum+=p->info;}}cout<<endl<<"關鍵路徑的長度為:"<<sum<<endl;return1;}voidmain(){CreateGraph(G);CriticalPath(G);cout<<"該圖其中之一的關鍵路徑為:"<<endl;inti;while(!StackEmpty(stack2)){PopStack(stack2,i);cout<<G.vertices[i].data<<"";}cout<<endl;DestroyGraph(G);}題目五:#include<iostream.h>#include<stdlib.h>#defineMAX_VERTEX_NUM20typedefstructArcNode{intadjvex; //該弧所指向的頂點的位置structArcNode指向下一條弧的指針//InfoType*info;}ArcNode;typedefstructVNode{chardata; //頂點信息ArcNode*firstarc; //指向第一條依附該頂點的弧的指針}VNode,AdjList[MAX_VERTEX_NUM];typedefstruct{AdjListvertices;intvexnum,arcnum; //圖的當前頂點數(shù)和弧intkind; //圖的種類標志}ALGraph;ALGraphG; //定義圖變量boolvisited[MAX_VERTEX_NUM]; //intnum=0;boolfound=false;intLocateVertices(ALGraphG,chara)//查找字符a在圖中的位置{for(inti=0;i<G.vexnum;i++)if(G.vertices[i].data==a)returni;return-1;}intLocateArc(ALGraphG,chara,charb)//判斷弧ab是否已經(jīng)存在于圖中,若已經(jīng)存在則返回1,否則返回0{ArcNode*p;if(LocateVertices(G,a)>=0){p=G.vertices[LocateVertices(G,a)].firstarc;while(p&&p->adjvex!=LocateVertices(G,b))p=p->nextarc;if(p)return1;return0;}return0;}void CreateGraph(ALGraph&G)//利用鄰接表存儲結(jié)構(gòu)構(gòu)造有向圖{inta,b;chars1,s2;ArcNode*p;for(inti=0;i<G.vexnum;i++){G.vertices[i].data='#';G.vertices[i].firstarc=NULL;}for(i=1;i<=G.arcnum;i++){cin>>s1;a=LocateVertices(G,s1);if(a<0){num++;G.vertices[num-1].data=s1;a=LocateVertices(G,s1);}cin>>s2;b=LocateVertices(G,s2);if(b<0){num++;G.vertices[num-1].data=s2;b=LocateVertices(G,s2);}if(!LocateArc(G,s1,s2)){p=newArcNode;if(!p)return;p->adjvex=b;p->nextarc=G.vertices[a].firstarc;G.vertices[a].firstarc=p;p=newArcNode;if(!p)return;p->adjvex=a;p->nextarc=G.vertices[b].firstarc;G.vertices[b].firstarc=p;}}}intFirstAdjVex(ALGraphG,intv)//查找圖中位置v的第一個鄰接點在圖中所在的位置{if(G.vertices[v].firstarc)returnG.vertices[v].firstarc->adjvex;return-1;}intNextAdjVex(ALGraphG,intv,intw)//查找相對于圖中位置v的鄰接點w的下一鄰接點在圖中的位置{ArcNode*p;p=G.vertices[v].firstarc;while(p->adjvex!=w)p=p->nextarc;if(p->nextarc)returnp->nextarc->adjvex;return-1;}voidDestroyGraph(ALGraph&G)//銷毀圖{ArcNode*p,*p1;for(inti=0;i<G.vexnum;i++){p=G.vertices[i].firstarc;if(p)p1=p->nextarc;while(p){deletep;p=p1;if(p1)p1=p1->nextarc;}}}voidDFSearch(ALGraphG,inti,ints)//查找i與s之間是否有路徑,以此來判斷二者是否連通,若連通found=true,否則found=false{intw;//for(intx=0;x<G.vexnum;x++)// visited[i]=true;for(w=FirstAdjVex(G,i);w>=0&&!found;w=NextAdjVex(G,i,w)){if(w==s){found=true;visited[s]=true;}elseif(!visited[w])DFSearch(G,w,s);}}voidDeleteArc(ALGraph&G,chara,charb)//刪除有向邊ab{ArcNode*p,*p1;if(LocateVertices(G,a)>=0){p1=G.vertices[LocateVertices(G,a)].firstarc;while(p1&&p1->adjvex!=LocateVertices(G,b)){p=p1;p1=p1->nextarc;}if(!p1)return;if(p1==G.vertices[LocateVertices(G,a)].firstarc){}else{}}

free(p1);p->nextarc=p1->nextarc;free(p1);return;}voidmain(){chara,b,k;intn;cin>>G.vexnum>>G.arcnum;CreateGraph(G);cin>>n;for(inti=1;i<=n;i++){found=false;cin>>k;{case'Q':cin>>a>>b;intx;for(x=0;x<G.vexnum;x++)visited[x]=false;DFSearch(G,LocateVertices(G,a),LocateVertices(G,b));if(found){}else{}

cout<<"C"<<endl;cout<<"D"<<endl;break;case'D':cin>>a>>b;DeleteArc(G,a,b);DeleteArc(G,b,a);break;default:cout<<"輸入有誤"<<endl;break;}}DestroyGraph(G);}題目六:#include<iostream.h>#include<stdlib.h>#defineMAX_VERTEX_NUM28typedefstructArcNode//弧結(jié)點定義{intadjvex; //該弧所指向的頂點的位置structArcNode*nextarc;//指向下一條弧的指針//InfoType*info;}ArcNode;typedefstructVNode//頂點結(jié)點定義{chardata; //頂點信息ArcNode*firstarc; //指向第一條依附該頂點的弧的指針}VNode,AdjList[MAX_VERTEX_NUM];typedefstruct//圖的定義{AdjListvertices;intvexnum,arcnum; //圖的當前頂點數(shù)和弧intkind; //圖的種類標志}ALGraph;ALGraphG; //定義圖變量boolvisited[MAX_VERTEX_NUM]; //訪問標志數(shù)intindegree[28]; //各結(jié)點入度數(shù)組intnum=0; //記錄頂點字符種類chara[28]; //存儲拓撲排序序列structStack棧類型定義{ints[21];inttop;};Stackstack; //intLocateVertices(ALGraphG,chara)//查找字符a在圖中的位置{for(inti=0;i<G.vexnum;i++)if(G.vertices[i].data==a)returni;return-1;}intLocateArc(ALGraphG,chara,charb)//判斷弧ab是否已經(jīng)存在于圖中,若已經(jīng)存在則返回1,否則返回0{ArcNode*p;if(LocateVertices(G,a)>=0){p=G.vertices[LocateVertices(G,a)].firstarc;while(p&&p->adjvex!=LocateVertices(G,b))p=p->nextarc;if(p)return1;return0;}return0;}void CreateGraph(ALGraph&G)//利用鄰接表存儲結(jié)構(gòu)構(gòu)造有向圖{inta,b;chars1,s2;ArcNode*p;for(inti=0;i<G.vexnum;i++){G.vertices[i].data='#';G.vertices[i].firstarc=NULL;}for(i=1;i<=G.arcnum;i++){cin>>s1;a=LocateVertices(G,s1);if(a<0){num++;G.vertices[num-1].data=s1;a=LocateVertices(G,s1);}cin>>s2;cin>>s2;b=LocateVertices(G,s2);if(b<0){num++;G.vertices[num-1].data=s2;b=LocateVertices(G,s2);}if(!LocateArc(G,s1,s2)){p=newArcNode;if(!p)return;p->adjvex=b;p->nextarc=G.vertices[a].firstarc;G.vertices[a].firstarc=p;}}}intFirstAdjVex(ALGraphG,intv)//查找圖中位置v的第一個鄰接點在圖中所在的位置{if(G.vertices[v].firstarc)returnG.vertices[v].firstarc->adjvex;return-1;}intNextAdj

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯(lián)系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經(jīng)權益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲空間,僅對用戶上傳內(nèi)容的表現(xiàn)方式做保護處理,對用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對任何下載內(nèi)容負責。
  • 6. 下載文件中如有侵權或不適當內(nèi)容,請與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論