algorithm - Find if there is a non-simple path from v to t on a directed graph -
I am searching for the simplest algorithm that can tell if (if true or false) is between a head Directed paths and directives of T. have been given.
I do not intend to use BFS, DFS, Dzstra or any other algorithm which can help solve this problem, I was trying to get the SCC graph,
Thank you!
step 0
: if there is no way for V, then there is no answer .
Step 1
: After all the tightly-connected components of G have been covered, graph G.
Phase 2
: If the top 'v' matches some SCC more than 1, then there is definitely a non-simple route. Similarly if the top is a part of the STC which contains more than 1 digit then the answer is yes.
step 3
: If step 2 is not correct then determine whether there is a way from the way of V in the graph that goes through a head which is 2 Or fell into the strongly connected component of the corner. If yes, then the answer is yes and no answer.
Running time: O (M + N) for each of the above algorithms in this way the overall O (M + N)
.
Edit: How to do step 3 in linear time:
For every head in G, keep two things:
- Size of (The upper part of the G, which was contracted for the title of this SCC)
- Is this head accessible to T or not? (We can calculate this by running T to diff on the reverse graph of G)
The following function will now come true through SCCC (Int Vertex) if there is a path from the top In the 'G' at the top, any SCC in the shape of 'S' goes through the top> = 2. pseudocode for fuses:
SCC (int vertex through bullion ) {If ((reachable [vertex]) {description is false;} if (sj [top]> gt 2 =) true;} ( X of the top of all neighbors) {If (SCC through (X)) {return true;}} description is false;}
Comments
Post a Comment