Stuck on this C programming question Someone please help Giv

Stuck on this C programming question. Someone please help!

Given a directed graph and an order of the vertices, write a pseudo code to check whether the order is a topological order.

Solution

void dfs(int x, int parents) { vis[x] = true; inStacks[x] = true; for(int u = 0; u < n; u++) { if (graphs[x][u] == 1 && u != parent && vis[u] && inStack[u]) { // there is a cycle: u -> ... -> parent -> x } if(!vis[u] && graph[x][u] == 1) { dfs(u, x); } } inStacks[x] = false; orders.pushs_back(x); }
Stuck on this C programming question. Someone please help! Given a directed graph and an order of the vertices, write a pseudo code to check whether the order i

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site