简体   繁体   English

如何找到图形的加权最小顶点覆盖

[英]How to find weighted minimum vertex cover of graph

So, I have a graph of vertices which have certain weights and edges. 因此,我有一个具有一定权重和边缘的顶点图。 I'm trying to find the minimum weighted vertex cover. 我试图找到最小加权的顶点覆盖率。 For example if I have a vertex cover of size 10 but each node has a weight of 10, then the weight of the total cover is 100. But if I have a vertex cover of size 99 with each node of weight 1, then I would pick this cover over the previous one. 例如,如果我有一个大小为10的顶点覆盖,但每个节点的权重为10,则总覆盖的权重为100。但是,如果我有一个大小为99的顶点覆盖,且每个节点的权重为1,则我会选择上一个封面。

This is NP-Complete I believe, so there's no efficient algorithm, but I think even an exhaustive search would work for me because the number of nodes will be relatively small. 我相信这是NP-Complete,所以没有高效的算法,但是我认为即使是详尽的搜索也对我有用,因为节点数量会相对较少。 The only way I can think to do this then would be to generate the power set of the set [1 ... n] (where each integer corresponds to a node on the graph), then test every individual set to see if it is 1) a valid vertex cover, and 2) keep track of the vertex cover of lowest weight. 我想到的唯一方法就是生成集合[1 ... n]的幂集(其中每个整数对应于图上的一个节点),然后测试每个单独的集合以查看是否为1)有效的顶点覆盖层,以及2)跟踪重量最低的顶点覆盖层。

But this seems horribly inefficient. 但这似乎效率很低。 Is this the best way to go about it? 这是最好的方法吗?

Minimum weight vertex cover is NP-Complete so you couldn't expect better than exhaustive search in general, but you could use backtracking to find a minimum weight vertex cover, something like this : 最小权重顶点覆盖率是NP-Complete,因此一般而言,您不能期望比穷举搜索更好,但是您可以使用回溯来找到最小权重顶点覆盖率,如下所示:

MinCover(Graph G, List<Vertex> selectedVertices, int min)
{
   var coveredAll = covered(G,selectedVertices);
   if ( coveredAll && weight(selectedVertices) < min)
   {
       cover = selectedVertices.ToList();
       min = weight(cover);
   }
   else if (!coveredAll && weight(selectedVertices) < min)
   {
      select another unvisited vertex and add it to selectedVertices
      call MinCover
      remove the previously selected vertex from the list
   }

   return;

}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM