Unweighted Paths on NetworkX X25538


Statement
 

networkx

pdf   zip

html

Given a directed graph with n vertices and m arcs, we wish to know if there is a directed path between two given vertices.

Input

Input starts with n and m. Then follow m pairs u,v, with uv, indicating an arc from u to v. We have that 0 ≤ u < n and 0 ≤ v < n and that there are no repeated arcs. Then follows a pair x, y with 0 ≤ x < n and 0 ≤ y < n.

Output

Write “yes” or “no” according to whether there is a path from x to y.

Observation

We are authorized to employ the NetworkX library.

Public test cases
  • 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
    
  • Information
    Author
    Language
    English
    Official solutions
    Python
    User solutions
    Python