For directed graph G(V, E) with n nodes, I want to create an integer array a, and its length is n. If there is a path from node 1 to 2, then a[1] <= a[2]
, if they are in the same strongly connected component a[1] = a[2]
, if if there is no path from node 2 to 3, we have a[2] > a[3]
.
I think the time complexity should be O(n + m), because the time complexity of seeking strongly connected component is it. But I am not sure how to output an array for it, could anybody help? Thanks.