Skip to content

Diagrams are wrong for Prim's algorithm (8.22) #99

Description

@varunbpatil

The following is the diagram for Prim's algorithm after the second iteration (i.e, node B has been removed from the priority queue and added to the MST).

image

The d values inside the nodes in the above diagram seem to come from adding the d value of node B to the corresponding edge weights (like in Dijkstra's algorithm)

d[D] = d[B] + 1 = 2 + 1 = 3
d[E] = d[B] + 4 = 2 + 4 = 6

which is wrong. Instead, the d values of nodes C, D and E should be just the edge weights from B.

d[C] = weight(B, E) = 1  // Was earlier 3
d[D] = weight(B, D) = 1  // Was earlier ∞
d[E] = weight(B, E) = 4  // Was earlier ∞

@bnmnetp

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions