Let G = (V, E) be a directed graph in which the vertices are labeled from 1 to |V|. For each vertex u, find the vertex v that is reachable from u (i.e., there is a path from u to v, or u and v are the same), and v has the smallest label among all the vertices reachable from u. For example, for the graph in Figure 22.2, the result should be 1→1, 2→2, 3→2, 4→2, 5→2, 6→6.

The solution is to construct the transpose of G, GT, then call DFS on the vertices in increasing order.

The program should be in JAVA and should take in a matrix from a text file.

I have been having trouble getting the right result. I need it to look like the picture attached. Thank you so much!