简体   繁体   English

带约束的二部图中的最大权重匹配

[英]Maximum weight matching in bipartite graphs with constraints

Assume that we have two sets: A=(a_1,a_2,...,a_m) and B=(b_1,b_2,...,a_n) (Not necessarily of same size). 假设我们有两个集合:A =(a_1,a_2,...,a_m)和B =(b_1,b_2,...,a_n)(不一定大小相同)。 A function F assigns a weight to each link from set A to set B: F:A*B->R. 函数F为从集合A到集合B的每个链接分配权重:F:A * B-> R。 So, for example, F(a_1,b_1)=2 means that the weight of the link between a_1 and b_1 is 2. The problem is to connect the elements of set A to those of set B in order to maximize the sum of the link weights satisfying these constraints: 因此,例如,F(a_1,b_1)= 2意味着a_1和b_1之间的链接的权重为2。问题是将集合A的元素连接到集合B的元素,以最大程度地增加集合A的元素。满足以下约束的链接权重:

  • The elements of set A must be matched to exactly one element of set B. 集A的元素必须与集B的一个元素完全匹配。
  • Elements of set B are allowed to have zero or more matching (0,1,2...) although a constraint on the sum of weights C_i exists for the elements of B. That is, if we choose to connect a_1 to b_1, and a_2 to b_1, the sum of weights F(a_1,b_1)+F(a_2,b_1) should be less than or equal to C_1. 尽管对B的元素存在权重之和C_i的约束,但允许集合B的元素具有零个或多个匹配(0,1,2 ...)。也就是说,如果我们选择将a_1连接到b_1,从a_2到b_1,权重F(a_1,b_1)+ F(a_2,b_1)的总和应小于或等于C_1。 This constraint is there for all elements of B. B的所有元素都有此约束。

I have searched for some ideas and I looked into the assignment problems and the Hungarian algorithm. 我已经搜索了一些想法,并研究了赋值问题和匈牙利算法。 The additional thing is that none of these consider the second constraint I have. 另一件事是这些都不考虑我的第二个约束。 Do you have any ideas on how to solve this? 您对如何解决这个问题有任何想法吗?

Thanks 谢谢

It's NP-hard. 这是NP难题。

Take a subset-sum instance {x 1 , x 2 , ..., x n }, where x i > 0 and a number k. 取一个子集和实例{x 1 ,x 2 ,...,x n },其中x i > 0和一个数字k。 Create a bipartite graph where left vertices are {a 1 , ..., a n }, right vertices are {b 1 ,b 2 }, and: 创建一个二部图,其中左顶点为{a 1 ,...,a n },右顶点为{b 1 ,b 2 },并且:

F(a i , b 1 ) = x i F(a i ,b 1 )= x i

F(a i , b 2 ) = 0 F(a i ,b 2 )= 0

C 1 = k C 1 = k

C 2 = 0 C 2 = 0

So you can take the number x i by connecting a i with b 1 , and leave it by connecting with b 2 . 因此,您可以通过将i与b 1连接来获取x i的值,而通过与b 2连接来保留数字x i Obviously there is a weight k matching iff the subset sum instance has a solution. 显然,如果子集和实例具有解,则权重k匹配。

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

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