Unweighted Paths on NetworkX X25538


Statement
 

networkx

pdf   zip

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

Input

Input starts with nn and mm. Then follow mm pairs u,vu,v, with u≠vu \ne v, indicating an arc from uu to vv. We have that 0≤u<n0 \leq u < n and 0≤v<n0 \leq v < n and that there are no repeated arcs. Then follows a pair xx, yy with 0≤x<n0 \leq x < n and 0≤y<n0 \leq y < n.

Output

Write “yes” or “no” according to whether there is a path from xx to yy.

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