the concept of perfect matching in wiki:
A perfect matching is a matching that matches all vertices of the graph. That is, a matching is perfect if every vertex of the graph is incident to an edge of the matching.
So the minimum-weight perfect matching is one of combinations which has smallest weight. At first, my idea is following greedy algorithm(Notice: my graph is complete, each vertex have edges to rest of vertices):
Picking one vertex from the graph and find its closest neighbor vertex in each step, then drop them and do the loop until there is no vertex in the graph. However, it is not optimal unless calcualting n! times:
while odd_vert:
v = vertices.pop()
length = float("inf")
closest = 0
for u in odd_vert:
if graph[v][u]["weight"] < length:
length = graph[v][u]["weight"]
closest = u
graph_minimum_match.add_edge(v, closest, weight = length)
I find some function in networkx but it ask the graph is bipartite:
nx.algorithms.bipartite.matching.minimum_weight_full_matching(G, top_nodes=None, weight='weight')
Besides, find the maximum weight matching:
nx.algorithms.matching.max_weight_matching(G, maxcardinality=True)
Then, I search an article shows blossom belief propagation, but I am not sure if it can be achieved, so any idea of it?