#T25. 最短路
最短路
Description
Given a weighted undirected graph with edges and vertices, find the shortest path from vertex to vertex .
Input Format
The first line contains two integers: and (, ).
The next lines each contain three positive integers: , , and , indicating that there is a path of length between vertices and , where .
Output Format
An integer representing the shortest distance from vertex to vertex .
4 4
1 2 1
2 3 1
3 4 1
2 4 1
2
Hint
【Sample Explanation】 Note that the graph may contain multiple edges and self-loops. The data guarantees there is a path connecting node to node .