% The program can detect only 1 path in any size network. There many be
% many other paths. The code is short. The total number of paths will be
% displayed
% change min to max for longest path
% 0 menas nodes not connected
% 0.0001 means that the arc exsits but the cost value is 0. 
% numpath= maximum number of paths. Some paths may be redundant.
clc
f=0;
P=0;

Path=0;
Length=0;
c=[
0	0	0	22	0	0	0	11	0	0	0	0.1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0.1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0.1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0.1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	7	0	0	0.1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	7	0	0	0.1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0	7	0	0	0.1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	14	0	0	7	0	0	0.1	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	14	0	0	7	0	0	0.1	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0	14	0	0	7	0	0	0.1	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	21	0	0	14	0	0	7	0	0	0.1	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	21	0	0	14	0	0	7	0	0	0.1	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0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0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0

];
count=0;
temp=zeros(1,2);
d=0;
f=0;
D=size(c); % it is a 1 row 2 column matrix, with the number of rows in position (1,1) and # of columns in position (1,2)
f(D(1,1),1)=0; % creates 1-column matrix f with 0 in all the rows where the number of rows equal the number of rows in D
for i= D(1,1)-1:-1:1
    count=0;
    for j=i:1: D(1,1)
         if c(i,j) ~= 0
             count=count+1;
             temp(count,1)= c(i,j)+f(j,1);
             temp(count,2)= j; % records the value of all nodes j that is connected to node i
         end
    end
    f(i,1)=max(temp (:,1)); % change min to max for longest path
    cz=2;
    G=size(temp);
    for k=1:1:G(1,1)
        if f(i,1)==temp(k,1) % if min (max) f value is matched
            f(i,cz)=temp(k,2); % record the node j that gave the min (max). f will grow in # of columns if there are multiple nodes that return the same f value
        cz=cz+1;
        end
    end
     temp=zeros(1,2);
end
f;

% following detects the number of multiple optimal solutions
cv=0;
     H=size(f);
          numpath=1;
for y=1:1:H(1,1)-1
       cv(y,1)=0;  
    for x=2:1:H(1,2)
        if f(y,x)~= 0
            cv(y,1)=cv(y,1)+1;
        end
      
    end 
      numpath=numpath*cv(y,1);
    
end        
jj=max(cv);  
  numpath
F=f; 


  
HH=size(F);
    for i=1:1:HH(1,1)
    for j=2:1:HH(1,2)
    if F(i,j)==0;
F(i,j)=D(1,1);
    end
    end
     end


% following detects the path in terms of column number in the c and X matrix.         
   L=2;
        rr=3;
        P(1,L-1)=1;
        P(2,L-1)=F(1,L);  
        while P(rr-1,L-1)<D(1,1)
       P(rr, L-1)=F(P(rr-1,L-1),L);
        rr=rr+1;
        end
    
   f;
   F;

  Length=F(1,1)
  Path=P 

  % following detects the path in terms of action number for each state from the X matrix.  
  szp=size(Path);
  action=0;
  for j=1:1:szp(1,2)
     
for i=1:1:szp(1,1)-1
  rown(i,1)=Path(i,j);
  rown(i,2)=Path(i+1,j);
  if rown(i,2)~=0
  action(i,j)=X(rown(i,1),rown(i,2));
  end
end
  end
action

 
% cij matrix Fig 3  week 1 notes  
% 0	3	2	0	0	0	0
% 0	0	0	4	1	0	0
% 0	0	0	2	0	0	0
% 0	0	0	0	3	4	0
% 0	0	0	0	0	0	5
% 0	0	0	0	0	0	1
% 0	0	0	0	0	0	0
%Act matrix Fig 3  week 1 notes 
% 0	2	3	0	0	0	0
% 0	0	0	4	5	0	0
% 0	0	0	4	0	0	0
% 0	0	0	0	5	6	0
% 0	0	0	0	0	0	7
% 0	0	0	0	0	0	7
% 0	0	0	0	0	0	0


%********************************
% cij matrix Fig 11 week 1 notes  
% 0	4	3	0	0	0
% 0	0	0	3	2	0
% 0	0	0	0	3	0
% 0	0	0	0	0	2
% 0	0	0	0	0	2
% 0	0	0	0	0	0
%Act matrix Fig 11 week 1 notes 
%          0 2 3 0 0 0
%          0 0 0 4 5 0
%          0 0 0 0 5 0
%          0 0 0 0 0 6
%          0 0 0 0 0 6
%          0 0 0 0 0 0 
%********************************



% 
% cij matrix Fig 8  week 1 notes  
% 0	1	2	0	0	0	0	0	0
% 0	0	0	6	12	0	0	0	0
% 0	0	0	3	0	4	0	0	0
% 0	0	0	0	4	3	15	7	0
% 0	0	0	0	0	0	7	0	0
% 0	0	0	0	0	0	0	7	15
% 0	0	0	0	0	0	0	0	3
% 0	0	0	0	0	0	0	0	10
% 0	0	0	0	0	0	0	0	0

%Act matrix for Fig 8 week 1 notes
% 0	2	3	0	0	0	0	0	0
% 0	0	0	4	5	0	0	0	0
% 0	0	0	4	0	6	0	0	0
% 0	0	0	0	5	6	7	8	0
% 0	0	0	0	0	0	7	0	0
% 0	0	0	0	0	0	0	8	9
% 0	0	0	0	0	0	0	0	9
% 0	0	0	0	0	0	0	0	9
% 0	0	0	0	0	0	0	0	0
%%********************************

% cij matrix page inv control problem from class notes

% c=[
% 0	4	5.5	7	8.5	10	0	0	0	0	0	0	0	0	0	0	0
% 0	0	0	0	0	0	6	7.5	9	100	100	0	0	0	0	0	0
% 0	0	0	0	0	0	5	6.5	8	9.5	100	0	0	0	0	0	0
% 0	0	0	0	0	0	4	5.5	7	8.5	10	0	0	0	0	0	0
% 0	0	0	0	0	0	0.0001	4.5	6	7.5	9	0	0	0	0	0	0
% 0	0	0	0	0	0	100	0.5	5	6.5	8	0	0	0	0	0	0
% 0	0	0	0	0	0	0	0	0	0	0	5	6.5	8	9.5	100	0
% 0	0	0	0	0	0	0	0	0	0	0	4	5.5	7	8.5	10	0
% 0	0	0	0	0	0	0	0	0	0	0	0.0001	4.5	6	7.5	9	0
% 0	0	0	0	0	0	0	0	0	0	0	100	0.5	5	6.5	8	0
% 0	0	0	0	0	0	0	0	0	0	0	100	100	1	5.5	7	0
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	7
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	6
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	5
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	4
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0.0001
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
% ];

% %ACtion X matrix page inv control problem from class notes
% X=[
% 0	1	2	3	4	5	0	0	0	0	0	0	0	0	0	0	0
% 0	0	0	0	0	0	3	4	5	6	7	0	0	0	0	0	0
% 0	0	0	0	0	0	2	3	4	5	6	0	0	0	0	0	0
% 0	0	0	0	0	0	1	2	3	4	5	0	0	0	0	0	0
% 0	0	0	0	0	0	0	1	2	3	4	0	0	0	0	0	0
% 0	0	0	0	0	0	-1	0	1	2	3	0	0	0	0	0	0
% 0	0	0	0	0	0	0	0	0	0	0	2	3	4	5	6	0
% 0	0	0	0	0	0	0	0	0	0	0	1	2	3	4	5	0
% 0	0	0	0	0	0	0	0	0	0	0	0	1	2	3	4	0
% 0	0	0	0	0	0	0	0	0	0	0	-1	0	1	2	3	0
% 0	0	0	0	0	0	0	0	0	0	0	-2	-1	0	1	2	0
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	4
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	3
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	2
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	1
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0
% 
% ];

%**********************************************
% cij matrix page 25 denardo prob 1
% c=[
%      0    20    23   100     0     0     0     0     0     0     0
%      0     0     0     0    17    20   100     0     0     0     0
%      0     0     0     0    13    20    23     0     0     0     0
%      0     0     0     0   100    17    24     0     0     0     0
%      0     0     0     0     0     0     0    17    20   100     0
%      0     0     0     0     0     0     0    13    20    23     0
%      0     0     0     0     0     0     0   100    17    24     0
%      0     0     0     0     0     0     0     0     0     0    17
%      0     0     0     0     0     0     0     0     0     0    13
%      0     0     0     0     0     0     0     0     0     0   100
%      0     0     0     0     0     0     0     0     0     0     0
% 
% ];
% ACtion matrix page 25 denardo prob 1
% X=[
%    0     1     2     3     0     0     0     0     0     0     0
%      0     0     0     0     1     2     3     0     0     0     0
%      0     0     0     0     0     1     2     0     0     0     0
%      0     0     0     0    -1     0     1     0     0     0     0
%      0     0     0     0     0     0     0     1     2     3     0
%      0     0     0     0     0     0     0     0     1     2     0
%      0     0     0     0     0     0     0    -1     0     1     0
%      0     0     0     0     0     0     0     0     0     0     1
%      0     0     0     0     0     0     0     0     0     0     0
%      0     0     0     0     0     0     0     0     0     0    -1
%      0     0     0     0     0     0     0     0     0     0     0
% ];

%*****************************************

% cij investment
% 0	44	37	30	23	16	9	0.001	0	0	0	0	0	0	0	0
% 0	0	0	0	0	0	0	0	0.001	0	0	0	0	0	0	0
% 0	0	0	0	0	0	0	0	10	0.001	0	0	0	0	0	0
% 0	0	0	0	0	0	0	0	13	10	0.001	0	0	0	0	0
% 0	0	0	0	0	0	0	0	16	13	10	0.001	0	0	0	0
% 0	0	0	0	0	0	0	0	19	16	13	10	0.001	0	0	0
% 0	0	0	0	0	0	0	0	22	19	16	13	10	0.001	0	0
% 0	0	0	0	0	0	0	0	25	22	19	16	13	10	0.001	0
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0.001
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	9
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	13
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	17
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	21
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	25
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	29
% 0	0	0	0	0	0	0	0	0	0	0	0	0	0	0	0



%X investment
% 0	6	5	4	3	2	1	0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