% This takes into Prob and Prob1, and generates all possible 2-hop range
% constraints.
% This generates r(k)=radio range. In DO loop 12 of sensor_esdp_routine,
% r(k) is squared.

clear

load Prob
load Prob1

DD = dd + dd';
lb_max = max(DD)';
rr = sparse(n,n);
DD = sign(DD);

% multiply the adjacency matrix
BB = DD*DD;

k = 0;
for i = 1:n-m
  for j = i+1:n
    % record i,j pair if (i,j) is not an edge, i not equal j, and that i is
    % joined to j by a path of length 2
    if BB(i,j) > 0 && DD(i,j) == 0 && i ~= j
      k = k+1;
      radio = max(lb_max(i),lb_max(j));
      head2(k) = i;
      tail2(k) = j;
      r(k) = radio;
      rr(i,j) = radio;
    end
  end
end

ndd = k;

fprintf(' done \n')

save Prob2 dim x nd d head tail n m head2 tail2 r ndd
save Prob PP m dd rr
      