Tail recursive algorithm for generating all topological orderings in a graph
问题 Given a graph i need to generate all topological orderings. For instance, given the following graph: i want to generate all topological orderings, which are: 2 4 7 5 2 7 4 5 2 4 5 7 Because many topological orderings may exist, I need to generate them lazily. Currently, I have a working implementation that is recursive and works on top of the scala-graph library: import scalax.collection.Graph import scalax.collection.GraphPredef._ import scalax.collection.GraphEdge._ import scala.collection