networkx
Given a directed graph with vertices and arcs, we wish to know if there is a directed path between two given vertices.
Input starts with and . Then follow pairs , with , indicating an arc from to . We have that and and that there are no repeated arcs. Then follows a pair , with and .
Write “yes” or “no” according to whether there is a path from to .
We are authorized to employ the NetworkX library.
Input
8 10 1 4 4 6 7 2 7 5 0 3 2 5 5 2 6 3 1 0 0 1 1 3
Output
yes
Input
8 10 1 4 4 6 7 2 7 5 0 3 2 5 5 2 6 3 1 0 0 1 7 6
Output
no