Get the latest tech news
Show HN: The Algorithm Behind the Topological Sort Library TopoSort
Topological sort library in Zig. Contribute to williamw520/toposort development by creating an account on GitHub.
The main idea is to iteratively find the successive root sets of the graph after removing them at each round. A partial list of the topological order nodes can be produced at the end. After the main iteration, any nodes not in the "rooted" list can be classified as parts of the cycles since they were not reachable due to the prior cycle skipping when traversing the dependents of root nodes.
Or read this on Hacker News