Unweighted Paths on NetworkX

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.

Problem information

Author: José Luis Balcázar, based on problem P56483 by Jordi Petit

Generation: 2026-01-25T14:36:17.396Z

© Jutge.org, 2006–2026.
https://jutge.org