Final Challenge #1
Lesson 8 of 9 in Coddy's Topological Sort - Graph Algorithms course.
Challenge
MediumKahn's algorithm doubles as a cycle detector.
Write a function named hasCycle that takes n and the flat edges array (directed) and returns 1 if the graph contains a cycle, or 0 if it is acyclic.
Hint: run Kahn's algorithm. If it manages to place all n vertices, the graph is acyclic; if it gets stuck with vertices left over, there is a cycle.
Try it yourself
#include <stdlib.h>
int hasCycle(int n, int* edges, int edges_size) {
// Write code here
return 0;
}