A basic algorithm for traversing a graph is called Breadth First Search. Use one of these algorithms on a given graph to determine if it is possible to reach one node from another.
Input Specification
The first line of input is an integer representing the number of nodes in this graph. They are numbered to .
The second line of input is an integer representing the number of edges in this graph.
The next lines represent an edge. They contain two space separated integers representing an edge between those nodes. These edges may not be unique.
Output Specification
If it is possible to reach node from node , print yes
. Otherwise print no
.
Sample Input
6
8
0 2
0 4
0 5
1 4
1 5
2 3
2 4
4 5
Sample Output
yes
Comments
deep
This comment is hidden due to too much negative feedback. Click here to view it.