-->

how to represent being minimum spanning tree in li

2019-09-02 05:06发布

问题:

suppose we are given a weighted graph G and a spanning tree T of it.we want to change weights of edges so that T be a minimum spanning tree and sum of all |w_i - w'_i| be minimum where w_i is the weight of edge i_th and w'_i is the weight of edge i_th after changing it.

I think it's obvious our goal is to minimize sum of |w_i - w'_i| for all i and our variables are w'_i but i can't find how to represent T is minimum spanning tree in constrains.

回答1:

For each i such that the ith edge is not in T, for each j such that the jth edge lies on the unique path in T from one endpoint of the ith edge to the other, there is a constraint wi' - wj' ≥ 0.



回答2:

You could use a modified version of Prim's algorithm.

This algorithm builds up a connected component, at each point adding the edge with lowest weight from the component to a vertex outside the component.

Note that at each stage there will be exactly one edge (call it e) in your original spanning tree that connects the component to a vertex outside the component, but there may be additional edges in the graph.

You can examine all the potential edges (from the component to outside the component) and compute the minimum weight. Then you need to change edge e from having its original weight to having the computed minimum weight.

You can then add edge e to the component and repeat until you have computed the minimal spanning tree using all of the original spanning tree edges.