[英]Find graph colouring that minimises sum of weights of edges that share vertex colours
Suppose we have a weighted complete graph with n vertices.假设我们有一个带有 n 个顶点的加权完全图。 We want to colour each vertex one of k colours.
我们想为每个顶点着色 k 种颜色。 The cost of any colouring is the sum of the weights of all edges that connect vertices of the same colour.
任何着色的成本是连接相同颜色顶点的所有边的权重之和。
For my use case, n will be around 20-50.对于我的用例,n 将在 20-50 左右。 For k = 2, 3 brute force worked fine, but I would ideally like a solution for any k.
对于 k = 2, 3 蛮力工作正常,但理想情况下我想要任何 k 的解决方案。 It is also the case that the graphs I'm dealing with have reasonable sparsity, but again, I would ideally like to solve the general case.
我正在处理的图表也具有合理的稀疏性,但同样,我理想地希望解决一般情况。
A first start could be to throw this at a MIQP solver.第一个开始可能是把它扔给 MIQP 求解器。 It can be linearized into a MIP (that is what Cplex is doing automatically).
它可以线性化为 MIP(这是 Cplex 自动执行的操作)。
min sum( (arcs(i,j),c), w(i,j)*x(i,c)*x(j,c)) (sum over all arcs i<j and colors c)
sum(c, x(i,c)) = 1 for all nodes i
x(i,c) in {0,1}
With 50 nodes, weights 25% dense, k=5 it took me a couple of seconds to solve to optimality (but can be much more depending on the data; many zero weights makes the problem easier).有 50 个节点,权重 25% 密集,k=5,我花了几秒钟来解决最优问题(但可能更多取决于数据;许多零权重使问题更容易)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.