Answer by ayushkamadji for Graph theory algorithm to find vertex with...
It can be done in O(n) if you represent the directed graph with two adjacency list, one representing going into the node and another going out of the node.In-listA -> B, CB -> DC -> D ->...
View ArticleAnswer by Ghasem for Graph theory algorithm to find vertex with out-degree 0...
I agree with Beta, there is no way you can solve this problem by o(n), because you have to visit each edge at least once to verify that it is a get-stuck node.
View ArticleAnswer by Beta for Graph theory algorithm to find vertex with out-degree 0...
(I assume that n is vertices and m is edges.)Note that there is at most one get-stuck vertex in a graph.Suppose we have an O(n) algorithm. If m is large, we must reach a conclusion without considering...
View ArticleGraph theory algorithm to find vertex with out-degree 0 and in-degree (n-1)
I'm wondering how to determine whether a directed graph has a get-stuck vertex, which is defined as a vertex with in-degree n-1 and out-degree 0. I guess the dumb way would be to print the in-degree...
View Article