注:以下的代码考研一般不要求写出。
 拓扑排序和关键路径都很重要!!重在理解
 越学到后面可能会混,这是正常的,我们要心平气和地接受,但是不是破罐子破摔,而是一开始不要太苛责自己。不太熟就多搞几轮。重复是记忆之母!
邻接矩阵存储结构的 NextNeighbor 函数:
 int NextNeighbor(MGraph& G,int x,int y){
 if(x!=-1&&y!=-1){
 for (int col=y+1;col < G.vexnum;col++)
 {
 if(G.Edge[x][col] > 0&&G.Edge[x][col] < maxWeight)
 return col; //maxWeight代表∞
 }
 }
 return -1;
 }
邻接表做存储结构
 int NextNeighbor(ALGraph& G,int x,int y){
 if(x!=-1){ //顶点x存在
 ArcNode *p=G.vertices[x].first; //对应边链表第一个边结点
 while(p!=NULL&&p->data!=y) //寻找邻接顶点Y
 p=p->next;
 if(p!=NULL&&p->next!=NULL)
 return p->next->data; //返回下一个邻接顶点
 }
 return -1;
 }










