On Fri, 27 Sep 2013, Dominique Devienne wrote:What behavior do you get from them? What is broken in those two cases
For my own education, why "singleton" vertices and duplicate edges make topological_sort break?
It is probably deterministic (looking at the code), assuming your graph data structure preserves edge order.
But what brings me here today is to ask about a "stable" topo-sort. When I have several vertices which are all
"unrelated" and thus sort at the same "level", topological_sort does not preserve the relative order of those
"sibling" vertices, and I'd like something fully deterministic that I can count on.
Is the order of outgoing edges always backwards from what you want (I suspect it is)? If so, reversing the order when putting the edges into the graph would be an easy fix to the issue.What are my options? Does BGL provide something like this?
As a concrete example, given tables A, B, C, with A depending on both B, C, topological_sort gives me the C, B, A
order (or adding the "levels" (C, B), A), while I'd like B, C, A, i.e. preserving the relative order of B, C.
The right way to do that, most likely, is to use a proper multi-processor scheduling algorithm (not straight topological sort, which only works ideally for one processor) to assign tables to processors. Work-stealing is likely to behave well, also, is simple, and can handle the case where task times are unpredictable.Thanks for any insight. --DD
PS: What about getting a topo-sort, but which also gives you the "levels", so that you can schedule those
independent tasks (on each level) in parallel for example? Does BGL provide something like this? I've done it in the
past with the help of the Sedgewick book, but I see a single topo-sort in BGL.