% lightpathPathComputation
%
%>> Usage: [sequenceOfNodeIDs , sequenceOfFiberIDs , sequenceOfWavelengthIDs] =...
% lightpathPathComputation (lpID , phys, netState)
%
%>> Abstract: This function computes the path of a lightpath from the
% network state, the physical topology and the lightpath ID .
%
%>> Arguments:
% o In:
% . lpID: Identifier number of the lightpath.
%
% . netState: NetState Structure. More information about netState in
% section "Structure of netState variable" from Help.
%
% . phys: Phys Structure. More information about netState in section
% "Structure of phys variable" from Help.
%
% o Out:
% . sequenceOfNodeIDs: Row vector with the sorted sequence of IDs of
% the nodes which the lightpath consist of.
% sequenceOfFiberIDs: Row vector with the sorted sequence of IDs of
% the links which the lightpath consist of.
% . sequenceOfWavelengthIDs: Row vector with the sorted sequence of
% wavelength IDs used in each link which the lightpath consist of.
function [sequenceOfNodeIDs , sequenceOfFiberIDs , sequenceOfWavelengthIDs] =...
lightpathPathComputation (lpID , phys, netState)
if (nargin==0), help lightpathPathComputation;return, end %help calling
if (nargin~=3), error('1: Incorrect number of arguments.'),end %Number of input arguments different of 3
%This function calculate the path of a lightpath from the network state and
%the lightpath ID .
currentNode = netState.lightpathTable (lpID,2);
egressNode = netState.lightpathTable (lpID,3);
mixedSequenceOfLinks=find(netState.lightpathRoutingMatrix (lpID,:)~=0);
mixedSequenceOfLinksTable=phys.linkTable(mixedSequenceOfLinks,1:2);
sequenceOfNodeIDs = currentNode;
sequenceOfFiberIDs = [];
sequenceOfWavelengthIDs = [];
while currentNode ~= egressNode
linkID=mixedSequenceOfLinks (find(currentNode==mixedSequenceOfLinksTable(:,1)));
nextNode = phys.linkTable (linkID,2);
sequenceOfNodeIDs = [sequenceOfNodeIDs nextNode];
sequenceOfFiberIDs = [sequenceOfFiberIDs linkID];
sequenceOfWavelengthIDs = [sequenceOfWavelengthIDs netState.lightpathRoutingMatrix(lpID,linkID)];
currentNode = nextNode;
end