I'd like to do an altered topological sort. At any given level, there are a number of choices we can take.
For example, the topological order of this graph could be 1 -> 2 -> 3 or 2 -> 1 -> 3.
My vertices has data associated as such.
struct VertexData {
int id;
int weight;
}
I'd like the topological sort to prioritise higher weights first whenever encountering a choice. So the order will always be 2 -> 1 -> 3 in this case.
How can I do this?
Edit: I'm using Vecs for both Edge and VertexList

Everything rides on the choice of graph model here.
The algorithm does not provide an extension point for initial vertex ordering. It just gets the out edges using the vanilla concept:
Any ordered/hashed container selector for
adjacency_list'sOutEdgeListparameter will compare only by the edge's target. All of this is implementation detail.As long as you're not using an ordered/hashed container selector, you might interfere and sort those out-edges manually, like I've showed before.
In this case I might be mistaken but it looks like you can get away with sorting the vertices ahead of creating the edges:
Live On Coliru
Printing