1、拓扑排序
void topsort() throws CycleFoundException{
Queue<Vertex> q = new Queue<>();
// 序号
int counter = 0;
for each Vertex v:
if(v.indegree == 0)
q.add(v);
while(!q.isEmpty()) {
Vertex v = q.poll();
v.topNum = ++ counter;
for each Vertex w adjacent to v :
if(-- w.indegree == 0)
q.add(w);
}
if(counter != VETICES_NUM)
throw new CycleFoundException();
}void topsort() throws CycleFoundExcept