I need to sort the nodes of a directed graph such that the number of arrows that flow backwards (against the sorting order) is minimal.
I can think of algorithms (e.g. keep swapping nodes until no swap will improve things) but I'm not sure how fast they run or whether they arrive at the best solution.
What is the name and complexity of this problem?