spanning tree with exactly k colored edges

雨燕双飞 提交于 2019-12-01 08:35:12

Let G_min = spanning tree with the minimum # of black edges.

Let G_max = spanning tree with the maximum # of black edges.

Let k_min = # of black edges in G_min

Let k_max = # of black edges in G_max

The proof goes as follows. Set G = G_min. Repeat for every black edge in G_max:

  1) If the edge is already in G, do nothing.
  2) If the edge is not in G, add it to G and remove another edge
     from the cycle thus induced in G.  Remove one not in G_max.

Step 2 is always possible because there is at least one edge not in G_max in every cycle.

This algorithm maintains the spanning-tree-ness of G as it goes. It adds at most one black edge per step, so G demonstrates a spanning tree with k black edges for all k between k_min and k_max as it goes.

Kruskal's will find you the minimum wight spanning tree - so inorder to find Gmin you need to do this the other way around. gmin = case all the black edged are giving the wight 1 and the white giving the wight 0. the way the algorithm first use all the white edgedes and then the black ones. this way we will get gmin.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!