% paths(el) - use path_index and perm_index to produce
% measurement index paths for K>1 el'th best.  Default el=1.

function p = paths(el)

global K;
global L;
global N;
global path_index;
global perm_index;
global combos;
global perms;

if( nargin == 0)
  el = 1;
end

if( (el < 1) | (el > L))
  error( '1 <= el <= L required');
end

if( K == 1)
  p = path_index(el,:);
  return;
end

p = combos(:,path_index(el,:));

for i=1:N
  c = p(:,i);
  p(:,i) = c(perms(:,perm_index(el,i)));
end

p = p';
