//拓扑排序
void TopsortbyQueue(ALGraph*G){
for(int i=0; i< G->vexNum;i++)
mark[i]=FALSE;
using std::queue;
queue<int> Q;
cout<<"拓扑序列为:"<<endl;
for(int i=0; i< G->vexNum;i++){
if(G->Indegree[i].indegree==0)
Q.push(i);}
while(!Q.empty()){
int v=Q.front();
Q.pop();
cout<<v;
mark[v]=TRUE;
for(Edge e=FirstEdge(G,v);isEdge(G,e);e=NextEdge(G,e)){
G->Indegree[e.to].indegree--;
if(G->Indegree[e.to].indegree ==0)
Q.push(e.to);
}
}
for(int i=0;i< G->vexNum;i++)
if(mark[i]==FALSE){
cout<<endl;
cout<<"还有顶点未访问,此图有环。"<<endl;
break;
}
}