Directional Graph Property / First Search Depth

As far as I know, it is possible if there is a path from vertex β€œa” to vertex β€œb” on any arbitrary oriented graph, then there may be some circumstance when, using the first search on the graph, this vertex β€œb” can be detected in the search after the vertex "a" has been processed. However, this is not possible for me (after extracting many graphs). Any ideas?

+4
source share
2 answers

No, your guess is wrong. It's impossible.

It is easy enough to prove by induction that when processing the vertex "a" all the vertices reached from "a" (for example, "b") are already detected.

+4
source
 (a) ---> (a1) ---->(b)
 |                   >
 |                   | 
 >                   |  
(a2)--------------->(a3)   

Consider this graph, vertex (a) has a path to vertex (b).

When we run dfs when starting from the top (a), the output is: (a), (a1), (b), (a2), (a3)

Summit (b) is visited after visit (a).

+1
source

Source: https://habr.com/ru/post/1585025/


All Articles