function pairlist = threepath(numatom);
%% threepath(numatom): makes a pair list (a graph) composed
%% of three paths through the nodes.  Each path is selected
%% independently at random.



path1 = [1,2,randperm(numatom-2) + 2];

% The first path starts with 1,2 to make sure the 1,2 edge
% goes in the graph.  The other two paths are random.

path2 = randperm(numatom);
path3 = randperm(numatom);

pairlist = [[path1(1:numatom-1)',path1(2:numatom)'];...
  [path2(1:numatom-1)',path2(2:numatom)'];...
  [path3(1:numatom-1)',path3(2:numatom)']];

% Each pair (i,j) is supposed to have i < j.  Flip
% pairs in the wrong order.

wrongord = (pairlist(:,1) > pairlist(:,2));
tmp = pairlist(:,1);
pairlist(logical(wrongord),1) = pairlist(logical(wrongord),2);
pairlist(logical(wrongord),2) = tmp(logical(wrongord));


