5.4.1 Pseudocode For The Prim Algorithm.
INPUT :n,c[e(ij)],i,j belonging to {1,...,n}.
OUTPUT :p(j) j=2,...,n (pointer of peaks j father in the T tree).
STEPS
- :(initializations).
O={1} (V(1) root of the T tree).
P={2,...,n}
For every j belonging to P :e(j):=c[e(j1)] , p(j)=1
( all peaks connected to the root.By definition of the cost function:e(j)=infinite when V(j)
does not connect to V(1).).
- Choose a k for which e(k)<=e(j) for every j belonging to P.In case of tight choose the
smaller one.
Exchange the O set with the set produced by the union of the O set and {k} . Exchange the P
set with the set produced by the difference of the P set and {k} .(P<-P-{k}) If P=0 then
stop.
- For every j belonging to P compare e(j) with c[e(kj)].
If e(j) >c[e(kj)] exchange e(j) <-c(e(kj)).Go back to Step 1.
HTML PAGE DIRECTOR :Papaioannou Panagiotis