Skip to content

bug in definition of "minimum-weight perfect matching" function #4

Open
@Shriyanshagro

Description

@Shriyanshagro

def minimum_weight_matching(MST, G, odd_vert):

The current approach doesn't ensure minimum weighted edges from odd_vert with no two edge-sharing same vertices.

the function should be instead:

def minimum_weight_matching(MST, G, odd_vert):
    vertices = []
    for W, u, v in sorted((G[u][v], u, v)
                          for u in G
                          for v in G[u]
                          if v in odd_vert and u in odd_vert):
        if u not in vertices and v not in vertices:
            length = G[v][u]
            MST.append((u, v, length))
            vertices.append(u)
            vertices.append(v)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions