Sorted is a topological sorted list of nodes in Graph. A
toplogical sort is possible if the graph is connected and
acyclic. In the example we show how topological sorting works
for a linear graph:
?- top_sort([1-[2], 2-[3], 3-[]], L).
L = [1, 2, 3]
The predicate top_sort/3 is a difference list version of
top_sort/2.