I'm trying to adapt this git page on simultaneously obtaining a topologically sorted list of incoming vertices whilst topologically sorting. The reason I'm doing this is to compare this implementation of transitive reduction with boost's undocumented version.
I'm trying to edit boost's own topological sort. From what I can tell, all I need to do is to override the discover_vertex or examine_edge functions to append a value to specific vectors depending on the vertex but I'm struggling to do so.
Should I pass in a data structure to the visitor or another OutputIterator? How can I properly override these functions and update either of these two options?
If anybody could shed some light that would be lovely. Many thanks in advance.
I was slightly wrong in my comment. I remembered
topological_sortas having a more general-purpose interface.So, let me show you how I'd replicate topological-sort directly against the
depth_first_searchinterface, which will will make it easy for you to modify the behavior to your taste.At this point it does nothing more than just the original
topological_sort. Indeed we can verify using the documentation example:Which prints the expected: Live On Coliru