Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added Donut Turbo C++/DONUT.EXE
Binary file not shown.
Binary file added Donut Turbo C++/DONUT.OBJ
Binary file not shown.
23 changes: 23 additions & 0 deletions Donut Turbo C++/Print_Topological_order.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
void printTopologicalOrder()
{
//Assuming nodes in 0-indexing 0->n-1
//n=no. of nodes, adj-> adjacency list representation of graph
vector<int>inDegree(n,0);
//updating in degree for each node:
for(auto x:adj) for(auto y:x) inDegree[y]++;
queue<int>q;
for(int i=0;i<n;i++) if(inDegree[i]==0) q.push(i);
vector<int>topo; //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";
}
1 change: 1 addition & 0 deletions Donut Turbo C++/README.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This program is to run a Donut program on turbo c++