#K75502. Total Edge Weight
Total Edge Weight
Total Edge Weight
You are given an undirected or directed graph described by n nodes and m edges. Each edge is represented as a triplet of integers (u, v, w), where u and v are nodes and w is the weight of the edge. Your task is to compute the total weight of all edges in the graph. Mathematically, if the weights of the edges are \(w_1, w_2, ..., w_m\), you need to compute:
The graph can have negative weights as well as large weights. Make sure to handle cases with no edges properly.
inputFormat
The input is given via standard input (stdin) in the following format:
n m u1 v1 w1 nu2 v2 w2 ... num m wm
Here, the first line contains two integers n and m. The following m lines each contain three integers representing an edge of the graph: the starting node u, the ending node v, and the weight w.
outputFormat
Print a single integer representing the total weight of all edges to standard output (stdout).
## sample5 4
1 2 4
2 3 5
3 4 6
1 5 10
25