diff --git a/Donut Turbo C++/DONUT.EXE b/Donut Turbo C++/DONUT.EXE new file mode 100644 index 0000000..a69cbd9 Binary files /dev/null and b/Donut Turbo C++/DONUT.EXE differ diff --git a/Donut Turbo C++/DONUT.OBJ b/Donut Turbo C++/DONUT.OBJ new file mode 100644 index 0000000..e5a05a2 Binary files /dev/null and b/Donut Turbo C++/DONUT.OBJ differ diff --git a/Donut Turbo C++/Print_Topological_order.cpp b/Donut Turbo C++/Print_Topological_order.cpp new file mode 100644 index 0000000..81b2bd2 --- /dev/null +++ b/Donut Turbo C++/Print_Topological_order.cpp @@ -0,0 +1,23 @@ +void printTopologicalOrder() +{ + //Assuming nodes in 0-indexing 0->n-1 + //n=no. of nodes, adj-> adjacency list representation of graph + vectorinDegree(n,0); + //updating in degree for each node: + for(auto x:adj) for(auto y:x) inDegree[y]++; + queueq; + for(int i=0;itopo; //to store the topological order + int s=0; //to store count of visited nodes + while(!q.empty()) + { + int x=q.front(); + q.pop(); + topo.push_back(x); + for(auto it:a[x]) + if(--inDegree[it]==0) q.push(it); + s++; // incrementing visited nodes + } + if(s==n) //print topo + else cout<<"The Graph is cyclic"; +} \ No newline at end of file diff --git a/Donut Turbo C++/README.txt b/Donut Turbo C++/README.txt new file mode 100644 index 0000000..19d0221 --- /dev/null +++ b/Donut Turbo C++/README.txt @@ -0,0 +1 @@ +This program is to run a Donut program on turbo c++