File tree Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Expand file tree Collapse file tree 1 file changed +2
-2
lines changed Original file line number Diff line number Diff line change @@ -37,8 +37,8 @@ Here we will do the exact opposite.
37
37
We try to add every edge that is not already in the MST.
38
38
39
39
1 . Sort the edges in $O(E \log E)$, then find a MST using Kruskal in $O(E)$.
40
- 2 . For each edge $e$ not already in the MST, temporarily add it to the MST, creating a cycle.
41
- 3 . Find the edge $k$ with maximal weight in the cycle that is not equal to $e$.
40
+ 2 . For each edge $e$ not already in the MST, temporarily add it to the MST, creating a cycle. The cycle will pass through the LCA.
41
+ 3 . Find the edge $k$ with maximal weight in the cycle that is not equal to $e$, by following the parents of the nodes of edge $e$, up to the LCA .
42
42
4 . Remove $k$ temporarily, creating a new spanning tree.
43
43
5 . Compute the weight difference $\delta = weight(e) - weight(k)$, and remember it together with the changed edge.
44
44
6 . Repeat step 2 for all other edges, and return the spanning tree with the smallest weight difference to the MST.
You can’t perform that action at this time.
0 commit comments