Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Add support for acyclic graphs and associated operations #154
"Topological sorting" is under-specified wrt the ordering of the independent vertices at each "level" of the sort. We could reflect this in the output type, by returning something like
This has two advantages:
This is related to this issue: #85, where a possible implementation of
One problem with deriving such "level vertex sets" is that the solution is not unique, as demonstrated by this simple example:
In an ideal world, I'd like to have the following signature of
scc :: Graph a -> Acyclic.Graph (NonEmpty.Graph a)
Now we could write functions like this:
topSort :: Acyclic.Graph a -> [a] batchLexicographic :: Acyclic.Graph a -> [Set a] batchWeighted :: Acyclic.Graph (a, Int) -> [Set a]
Where the latter does an optimal batching that aims to minimise the overall "execution time" of tasks associated with vertices. There are other interesting batching strategies, including dynamic ones.
To sum up: I'd like to have this functionality, but I think it shouldn't be a part of
Ah, of course it's not unique, my mistake! Then we can't give a "best" most general type for
So yes, this should be some kind of additional "batching" functionality, which might not even belong in this package.
Not sure if you want to keep this open for future reference, happy to close and I'll just implement my own thing.