Optimize connection between nodes in a graph [duplicate]

亡梦爱人 提交于 2020-01-25 20:58:56

问题


I am working on a problem which could be reduced to a graph optimization problem as below.

A set of colored nodes are given.

A set of rules are given about the cost contribution from the nodes.

Ex.

  • If a red node is not connected, cost is 100

  • If a red node connects to red node, cost is 10

  • If a red node connects to a blue node, cost is 20

  • Any node can have only 4 connections at max.

The problem is to optimize the connections (vertices) such that the total cost is minimized and the final graph obeys the rules.

I am wondering if this problem, maybe in some other way, known. If so, please provide any pointers that might be of help. Thanks.

( Please let me know if any of the tags should be removed. )


回答1:


1) In the case that the numbers of red and blue nodes are balanced, the optimal solution is a chain with alternating colours.

2) If you deviate from balance, you will want to connect your surplus nodes to nodes of the opposite colour with free slots.

3) If no 'free' slots are available, you will want to add the remaining nodes in subgraphs that are tree-like.

EDIT:

This solution only applies to the original formulation of the question, which indicated the existence of only 2 colours.



来源:https://stackoverflow.com/questions/43581690/optimize-connection-between-nodes-in-a-graph

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