L16-MST

5 while q 6 do u extract minq 7 for each v adj u 8 do

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 9 11 3 1 prim(G = (V, E )) 1Q ⇧ Q is a Priority Queue 2 Initialize each v ⇤ V with key kv ⇥, v nil 3 Pick a starting node r and set kr 0 4 Insert all nodes into Q with key kv . 5 while Q ⌅= ⇧ 6 do u extract-min(Q) 7 for each v ⇤ Adj (u) 8 do if v ⇤ Q and w(u, v ) < kv 9 then v u 10 decrease-key(Q, v, w(u, v )) i f Sets kv 6 w(u, v ) h prim 8b 8 d 0 g 7 10 a 8 8 7 3 c 5 e 9 12 2 9 11 3 1 prim(G = (V, E )) 1Q ⇧ Q is a Priority Queue 2 Initialize each v ⇤ V with key kv ⇥, v nil 3 Pick a starting node r and set kr 0 4 Insert all nodes into Q with key kv . 5 while Q ⌅= ⇧ 6 do u extract-min(Q) 7 for each v ⇤ Adj (u) 8 do if v ⇤ Q and w(u, v ) < kv 9 then v u 10 decrease-key(Q, v, w(u, v )) i f Sets kv 6 w(u, v ) h 5 prim 8b 8 d 0 g 7 10 a 8 8 7 3 c 5 e 9 12 2 9 11 3 1 prim(G = (V, E )) 1Q ⇧ Q is a Priority Queue 2 Initialize each v ⇤ V with key kv ⇥, v nil 3 Pick a starting node r and set kr 0 4 Insert all nodes into Q with key kv . 5 while Q ⌅= ⇧ 6 do u extract-min(Q) 7 for each v ⇤ Adj (u) 8 do if v ⇤ Q and w(u, v ) < kv 9 then v u 10 decrease-key(Q, v, w(u, v )) i f Sets kv 6 w(u, v ) h 5 prim 8b 8 d 0 g 7 10 a 8 8 7 3 c 5 e 9 12 2 9 11 3 1 prim(G = (V, E )) 1Q ⇧ Q is a Priority Queue 2 Initialize each v ⇤ V with key kv ⇥, v nil 3 Pick a starting node r and set kr 0 4 Insert all nodes into Q with key kv . 5 while Q ⌅= ⇧ 6 do u extract-min(Q) 7 for each v ⇤ Adj (u) 8 do if v ⇤ Q and w(u, v ) < kv 9 then v u 10 decrease-key(Q, v, w(u, v )) 11 i 6 6 Sets kv w(u, v ) f h 5 prim 8b 8 d 0 g 7 10 a 8 8 7 3 c 5 e 9 12 2 9 11 3 1 prim(G = (V, E )) 1Q ⇧ Q is a Priority Queue 2 Initialize each v ⇤ V with key kv ⇥, v nil 3 Pick a starting node r and set kr 0 4 Insert all nodes into Q with key kv . 5 while Q ⌅= ⇧ 6 do u extract-min(Q) 7 for each v ⇤ Adj (u) 8 do if v ⇤ Q and w(u, v ) < kv 9 then v u 10 decrease-key(Q, v, w(u, v )) 11 i 6 6 Sets kv w(u, v ) f h 5 prim 8b 8 d 0 g 7 10 a 8 8 3 3 c 1 5 e...
View Full Document

This note was uploaded on 02/25/2014 for the course CS 4102 taught by Professor Horton during the Spring '10 term at UVA.

Ask a homework question - tutors are online