Given a directed graph G = (V, E). A root vertex in G is a vertex v such that any other vertex u in G is reachable from v through a directed path. How to design a O(|V| + |E|) time algorithm that finds a root vertex (or reports that none exists).
Here`s O(|V| + |E|) approach:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.