C++ Fundamentals of Data Structures(C++ 자료구조론) 6.5 TopologicalOrder(위상정렬) 예제
/*AOV Topological, 위상정렬*/#include #include #include using namespace std; class Graph{ int vertices; //정점의 개수 list *adj; void topologicalSortUtil(int v, bool visited[], stack &Stack)//위상정렬에서 쓰이는 함수 { visited[v] = true; //현재 노드를 방문했다고 표시 //정점에 연결되어있는 모든 정점에 대해 재귀 list::iterator i; for (i = adj[v].begin(); i != adj[v].end(); i++) if (!visited[*i]) topologicalSortUtil(*i, visited, Stack); Stack.push..