编写算法实现建立图的邻接表StatusCreateAG(ALGraph
编写算法实现建立图的邻接表StatusCreateAG(ALGraph
编写算法实现建立图的邻接表StatusCreateAG(ALGraph&G){i...xtarc=p;}}returnOK;}
编写算法实现建立图的邻接表StatusCreateAG(ALGraph&G){i...xtarc=p;}}returnOK;}
编写算法实现建立图的邻接表 StatusCreateAG(ALGraph &G) { int n,e,k,i,j; cout<<"请输入顶点数:"; cin>>n; cout<<"请输入边数:"; cin>>e; G.vernum=n; G.arcnum=e; // 建立顶点数组 for(k=0;k>G.vertices[k
编写算法实现建立图的邻接表 StatusCreateAG(ALGraph &G) { int n,e,k,i,j; cout<<"请输入顶点数:"; cin>>n; cout<<"请输入边数:"; cin>>e; G.vernum=n; G.arcnum=e; // 建立顶点数组 for(k=0;k>G.vertices[k
编写算法实现建立图的邻接表StatusCreateAG(ALGraph&G){intn,e,k,i,j;cout<<'请输入顶点数:';cin>>n;cout<<'请输入边数:';cin>>e;G.vernum=n;G.arcnum=e;//建立顶点数组for(k=0;k>G.vertices[k].data;G.vertices[k].firstarc=NULL;}//建立邻接表VertexTypev1,v2;ArcNode*p,*q;for(k=0;k>v1>>v2;i=LocateVex(G,v1);if(i<0||i>G.vernum-1)returnERROR;j=LocateVex(G,v2);if(j<0||j>G.vernum-1)returnERROR;if(i==j)returnERROR;p=newArcNode;if(!p)returnERROR;p->adjvex=j;p->nextarc=NULL;q=G.vertices[i].firstarc;if(!q)G.vertices[i].firstarc=p;else{while(q->nextarc)__________//指针定位于邻接表的尾结点q->nextarc=p;}}returnOK;}
编写算法实现建立图的邻接表StatusCreateAG(ALGraph&G){intn,e,k,i,j;cout<<'请输入顶点数:';cin>>n;cout<<'请输入边数:';cin>>e;G.vernum=n;G.arcnum=e;//建立顶点数组for(k=0;k>G.vertices[k].data;G.vertices[k].firstarc=NULL;}//建立邻接表VertexTypev1,v2;ArcNode*p,*q;for(k=0;k>v1>>v2;i=LocateVex(G,v1);if(i<0||i>G.vernum-1)returnERROR;j=LocateVex(G,v2);if(j<0||j>G.vernum-1)returnERROR;if(i==j)returnERROR;p=newArcNode;if(!p)returnERROR;p->adjvex=j;p->nextarc=NULL;q=G.vertices[i].firstarc;if(!q)G.vertices[i].firstarc=p;else{while(q->nextarc)__________//指针定位于邻接表的尾结点q->nextarc=p;}}returnOK;}