% Will plot the original Valley network (as returned from ValleyNetwork.m), or the "processed" one, after running ProcessNetwork.m.

clear all; close all; clc;

L = 50; W = 50; ff = 0.06;% L,W are system dimensions. For archaic reasons (that you don't need to worry about), they are in units of HALF \ell, the unit of distance used in the paper. So set them to TWICE the value you want in units of \ell. ff is the fill factor, called 'f' in the paper. The definition of this parameter is the same as in the paper, so it is easy to set.

count = 4; % Noise realisation label

% For 'original' network, use this:
%folder = strcat('L',int2str(L),'W',int2str(W),'ff',num2str(ff));

% For processed network, use this:
folder = strcat('L',int2str(L),'W',int2str(W),'ff',num2str(ff),'P');

folder = strrep(folder,'.','_');
cd SimCity2; % Choose folder
cd(folder);
load(strcat('wrkspc',int2str(count),'.mat'));
cd ../..

figure; grid on; hold on;
% Plot the valley network
plot(extrema(:,1),extrema(:,2),'ko');
plot(maxima(:,1),maxima(:,2),'bx');
plot(minima(:,1),minima(:,2),'rx');
plot(saddles(:,1),saddles(:,2),'gx');

for k=1:length(C)
    traj = C{k,1};
    plot3(traj(1,:),traj(2,:),traj(3,:),'b.');
    traj = C{k,2};
    plot3(traj(1,:),traj(2,:),traj(3,:),'r.');
end

% And the candidate minimal paths from LLT
if 1 % Activate only for 'processed' networks
for k=1:length(C2)
    traj = C2{k,1};
    plot3(traj(1,:),traj(2,:),traj(3,:),'g.');
    traj = C2{k,2};
    plot3(traj(1,:),traj(2,:),traj(3,:),'k.');
end
end
