Union-Find/Disjoin-Set data structure for Directed Graph
问题 I'm looking for an efficient Union-Find (aka Disjoint Set) data structure for my directed graph, which has cycles and forests. Given such a graph G , I want to to answer following queries: Can I reach node v from u ? From which nodes, u is not reachable? For a single "source" node u , I can run DFS search and answer whether I can reach v from it. A single DFS search will have an upper-bound cost of m + n in the worst-case, where m and n are the number of vertices and edges in the graph,