this version problem differ constraint na tree connect undirected graph cycle a weight tree weight assign edge the distance vertice minimum sum weight path connect themyou give weight tree n vertex edge weight 1 Denote dv distance vertex 1 vertex vLet fx minimum possible value maxlimits_1 leq v leq n dv temporarily add edge weight x vertex b 1 le b le n Note operation graph long treefor integer x 1 n find fx