#include #include struct Edge { int u, v, weight; Edge(int u, int v, int weight) : u(u), v(v), weight(weight) {}; bool compareEdges(const Edge& a, const Edge& b) { if (a.weight == b.weight) { if (a.u == b.u) { return a.v < b.v; } return a.u < b.u; } return a.weight < b.weight; }