Problem Summary
Given an directed graph, find any topological order for it.
Solution
Topological sorting is a very classic algorithm. It can be implemented in many ways. I used Kahn’s algorithm.
For details, check this:
Topological sorting - Wikipedia
Code
|
|