%% prim demo

k = 10;

load nov7
a = dista(a,xy);
[ai,aj,av] = find(a);
a = sparse(ai,aj,1./av);


t = prim(a,1);
t = a .* t;
clf
plot(xy(:,1),xy(:,2),'o');
hold on
gplot(t,xy)

pause;


[ti,tj,tv] = find(triu(t));
[jnk,ord] = sort(tv);

tio = ti(ord(1:end-k));
tjo = tj(ord(1:end-k));
tk = sparse(tio, tjo, 1,100,100);

figure

plot(xy(:,1),xy(:,2),'o');
hold on
gplot(tk,xy)
