All pastes #375117 Raw Edit

RWA_test

public text v1 · immutable
#375117 ·published 2007-02-28 00:48 UTC
rendered paste body
% Program to resolve RWA
% User Enters the node information in form of a n*n matrix

% n=input('Enter Matrix Information: First Number of nodes   ');

% m=[];
% m=input('Enter the transmutation matrix    ');
m=[inf 1 1 1 inf
    1 inf 1 1 inf
    1 1 inf inf 1
    1 1 inf inf inf
    inf inf 1 inf inf];
n=length(m);

% path_no=input('Enter the number of paths to be computed')
% path_info=input('Enter the paths to be computed')
path_no=3;
path_info=zeros(3,2);
path_info=[1 3
           1 5
           2 4
           ];
       
 
 cost_tot=0;
 path_out=[];
 path_out=zeros(path_no,n);
 
  for i=1:path_no
      test123=pathonly(path_info(i,1), path_info(i,2), m);
      testlen=length(test123);
      cost_tot=cost_tot+costonly(path_info(i,1), path_info(i,2), m);
      for j=1:testlen
              path_out(i,j)=test123(j);
      end
  end
  
  for i=1:path_no
      for j=1:n
          if(path_out(i,j)==0)
              path_out(i,j)=inf;
          end
      end
  end
  
%path_out is the first solution to routing without wavelength assignment
  
  
%  test=matrow(path_out,1)
%   p=[];
%   for i=1:path_no
%       p(i)=matrow(path_out,i);
%   end

%now to find the number of overlaps and the overlapping shit
mo=m;
overlap=0;
path_outO=path_out;

%space out matrix
for i=path_no:path_no+1
    for j=n:n+1
        path_out(i,j)=inf;
    end
end

% path_out =[1     3   Inf   Inf   Inf     0
%            1     3     5   Inf   Inf     0
%            2     3     5   Inf   Inf   Inf
%            0     0     0     0   Inf   Inf];


for i=1:path_no
    for j=1:n
        if((path_out(i,j)==path_out(i+1,j))&(path_out(i,j+1)==path_out(i+1,j+1))&(path_out(i,j)~=inf)&(path_out(i,j+1)~=inf))
            overlap=overlap+1;
%Breaking the overlapping link

            m(path_out(i,j),path_out(i,j+1))=inf;
            m(path_out(i,j+1),path_out(i,j))=inf;
            path_test=pathonly(path_out(i,j),path_out(i,j+1),m);
            %cost_tot=cost_tot+costonly(path_out(i,j),path_out(i,j+1),m);
            len_test=length(path_test);
            path_copy=path_out;
            
            for k=len_test+1:n
                path_out(i,k+1)=path_copy(i,k);
            end
            
            for k=1:len_test
                path_out(i,k)=path_test(k);
            end
            
            
%                 path_out(i,j)
%                 path_out(i,j+1)
%                 path_out(i+1,j)
%                 path_out(i+1,j+1)
        end
    end
end