I\'m looking for a simple algorithm to \'serialize\' a directed graph. In particular I\'ve got a set of files with interdependencies on their execution order, and I want to
I've come up with a fairly naive recursive algorithm (pseudocode):
Map
The biggest problem with this is that it has no ability to detect cyclic dependencies - it can go into infinite recursion (ie stack overflow ;-p). The only way around that that I can see would be to flip the recursive algorithm into an interative one with a manual stack, and manually check the stack for repeated elements.
Anyone have something better?