Let G be a graph and V(G) = {v1, v2, …, vn}, where n ≥ 0. Recall that a topological ordering of V(G) is a linear ordering vi1 vi2, …, vin of the vertices such that if vij is a predecessor of vik, j ≠ k, 1 ≤ j ≤ n, 1 ≤ k ≤ n, then vij precedes vik, that is, j
In a depth-first topological ordering, we start with finding a vertex that has no successors (such a vertex exists because the graph has no cycles), and place it last in the topological order. After we have placed all the successors of a vertex in topological order, we place the vertex in the topological order before any of its successors. Clearly, in the depth-first topological ordering, first we find the vertex to be placed in topologicalOrder[n−1], then topologicalOrder[n−2], and so on.
Write the definitions of the C++ functions to implement the depth-first topological ordering. Add these functions to the class topologicalOrderType, which is derived from the class graphType. Also, write a program to test your depth-first topological ordering.
We need at least 10 more requests to produce the solution.
0 / 10 have requested this problem solution
The more requests, the faster the answer.