1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
program kruskal (input)
const maxV = 50, maxE=2500
type edge = record x,y weight: integer end;
var i,j,m,x,y,V,E:integer;
edges: array [0..maxE] of edge;
begin
readln(V,E);
for j:=1 to E do
begin
readln (c,d, edges[j].weight);
edges[j].x:=index(c);
edges[j].y :=index(d);
end;
findinit; pqconstruct; i:=0; // what is findinit? pqconstruct?
repeat
m:= pqremove; x:=edges[m].x; y:=edges[m].y; // what is pqremove?
if not fastfind(x,y,true) then // what is fastfind? how do I implement it?
begin
writeln(name(x),name(y), edges[m].weight);
i:=i+1;
end
until i=V-1
end.
|