_Algorithm Alley: Topological Sorting_
by Jonathan Pincus and Jerry Schwarz
Example 1:
topsort reports (correctly) that there is a cycle after 1 element
a
cycles reports (correctly) that there are two cycles
cycle 0: g f
cycle 1: d c b
topsortWithCycles reports (correctly) that there is a cycle
a
d
c
b
e
g
f
Example 2:
template
int
topsort (RandomAccessIterator begin,
RandomAccessIterator end, // members being sorted
InputIterator beginRel,
InputIterator endRel, // relations being sorted
OutputIterator result
)