如何找到圖的非完美二分匹配? (How can I find a non-perfect bipartite matching of a graph?)


問題描述

如何找到圖的非完美二分匹配? (How can I find a non‑perfect bipartite matching of a graph?)

That is, how can I find a bipartite matching of a graph where some vertices may not be connected to any other vertices?

EDIT: One more condition, suppose the edges are also weighted, and I'd like a matching such that the total edge weight is minimized (or maximized).

‑‑‑‑‑

參考解法

方法 1:

Use Hopcroft‑Karp algorithm, it does exactly what you want.

方法 2:

First, I'm going to assume your weights are nonnegative.

In your edited version, you're talking about the assignment problem: n agents are each assigned a unique action to perform, where each agent has an arbitrary non‑negative cost for each action.  Though this description is for perfect bipartite matching, you can perform a couple of tricks.  To balance out the sides, you can add vertices that have weight 0 to everything on the other side, to say that there is 0 cost associated with taking no action / an action not taken.  Missing links can be modeled by a cost exceeding the sum of all true costs, so they will only be selected if the problem is not solvable.  For your edited version, I would use the Hungarian Algorithm.  Finally, this problem is also known as "maximum weighted bipartite matching" and another reference to algorithms can be found in the second paragraph under maximum matchings in bipartite graphs.

EDIT: if you want to maximize cost rather than minimize it, you have to flip your costs around.  Just find the maximum cost and subtract each cost from the maximum.  Then you won't want to take any cost 0 links if you had missing links.

(by John ZhangThomashMartin Hock)

參考文件

  1. How can I find a non‑perfect bipartite matching of a graph? (CC BY‑SA 3.0/4.0)

#bipartite #data-structures #graph #algorithm






相關問題

如何找到圖的非完美二分匹配? (How can I find a non-perfect bipartite matching of a graph?)

如何使用 BFS 在無向二部圖中找到最短循環? (How can I find the shortest cycle in an undirected bipartite graph using BFS ?)

如何在有向圖中測試二分 (how to test for bipartite in directed graph)

檢查圖形是否是二分的 (check if the graph is bipartite or not)

二分圖中邊緣不同路徑的數量 (Number of edge distinct paths in bipartite graph)

對於來自兩個不同集合的項目的一對一分配,UI/UX 模式及其優缺點是什麼? (What are UI/UX patterns and their pros/cons for 1-to-1 assignments of items from two different sets?)

將多個函數應用於矩陣列表以返回數據框 (Apply multiple functions to list of matrices to return data frame)

如何將二分圖轉換為無二分圖 (How to convert a bipartite graph into no bipartite)

如何根據來自雙模網絡的匹配創建單模網絡(鄰接矩陣) (How to create a one-mode network (adjacency matrix) based on matches from two-mode network)

igraph 到達模型中屬性類型為“FALSE”的節點 (igraph reaching a node whose type of attribute in the model is "FALSE")

二分網絡igraph中的頂點屬性 (Vertex attributes in bipartite network igraph)

使用循環從 r 中的前一個列表創建一個新列表 (using loop to create a new list from previous list in r)







留言討論