Weighted Paths on NetworkX

Given a directed graph with nn vertices and mm weighted arcs, we wish to know the cost of the minimum-cost directed path between two given vertices, if there is one.

Input

Input starts with nn and mm. Then follow mm 3-tuples u,v,wu,v,w, with uvu \ne v, indicating an arc from uu to vv with weight ww. The following will be true: there are no repeated arcs, all weights are positive integers, 0u<n0 \leq u < n and 0v<n0 \leq v < n. Finally, there follows a pair xx, yy with 0x<n0 \leq x < n and 0y<n0 \leq y < n.

Output

Write the total cost (sum of arc weights) of the path from xx to yy of least cost, if one exists; otherwise, write “no path”.

Observation

We are authorized to employ the NetworkX library.

Problem information

Author: José Luis Balcázar, based on existing Jutge problems

Generation: 2026-01-25T13:50:10.406Z

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