Prim/Dijkstra Body

Prim/Dijkstra Body

While number of vertices in MST is less than |V| do

Find element y of Fringe_Set with minimum weight

Add vertex y and edge (y,Parent of y) to MST

Remove y from Fringe_Set

For all vertices z adjacent to y do

if z not in Fringe_Set then

Put z into Fringe_Set;

Set weight of z to weight of (y,z)

Set parent of z to y

else

if weight of (y,z) less than weight of z then

set weight of z to weight of (y,z)

set parent of z to y

endif

endif

endfor; endwhile

Previous slide Next slide Back to the first slide View Graphic Version