[ Jun 20 ]
For the past few days, I have been playing with tsort from GNU textutils and getting it to work properly even with cycles in the input. Turns out that with an incremental shortest path algorithm this can be done both efficiently and elegantly (*cough*).