Unweighted Paths on NetworkX

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 u ≠ v,
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.

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
