Connect nodes to maximize total edge weight

前端 未结 5 1238
情深已故
情深已故 2021-01-01 13:23

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

  • A set of colored nodes is given. They are all unconnected i.e. th

5条回答
  •  谎友^
    谎友^ (楼主)
    2021-01-01 13:56

    You can convert this to a problem of finding a perfect matching of maximum cost, which can be solved in polynomial time (e.g. using a variant of the Blossom algorithm )

    The conversion is to split each node of degree d into d left nodes and d-4 right nodes.

    For each pair of vertices u,v in the original graph, add an edge between an unconnected vertex u left node and an unconnected vertex v left node of weight equivalent to the profit of joining u and v.

    Next add extra edges (of weight 0) between every pair of left and right nodes (for the same vertex).

    Now construct the max weight perfect matching in this new graph.

    The point is that the extra edges use up all but 4 of the left nodes. This means that each vertex can only make profit from 4 of the profitable edges.

    Example

    Suppose we have a problem with 7 coloured nodes. I have drawn the section of the expanded graph that corresponds to the part for a single green node and a single red node.

    Note that there are 6 left green nodes, one less than the total number of coloured nodes. There are 2 right green nodes, four less than the number of left nodes. There is a single curved edge joining a greenleft node and a red left node. If this curved edge is chosen in the perfect matching it means that the red node should be joined to the green node.

提交回复
热议问题