【发布时间】:2015-02-17 16:31:09
【问题描述】:
我正在寻找一种有效的算法来找到两个特定图的最小成本顶点覆盖,其中顶点具有不同的成本。
第一个图是一个排序链表,其中 V={1...n} 和 E={{1,2},{2,3},{3,4}... {n-1,n}}
第二张图是一个简单的循环。与上面基本相同,但 {n,1} 也是一条边。
我已经找到了一种递归方法,通过简单地检查每个节点是否应该在顶点覆盖中。
VC(Graph G(V,E)):
if(|V|=0) return 0
u=first node of V
v=second node of V
return min(VC(Graph.remove(u)+cost(u), //Case where the first node is in VC
VC(Graph.remove(v,u))+cost(v)) //Case where second node is in VC
然而这确实是低效的,有没有办法使用动态编程来改进这一点?
【问题讨论】:
-
你可以使用那些特定图表的结构吗?否则你会有麻烦的..
-
是的!明确地。他们只需要为这些图表工作。
标签: algorithm graph dynamic-programming