Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@Shriyanshagro

Description

@Shriyanshagro
Issue body actions

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)
Reactions are currently unavailable

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.