from
MatPlanWDM v0.5
by Pablo Pavon MariƱo Educational network planning tool for the RWA problem in WDM networks (MILP and heuristic based)
trans_trafficMatrix2flowTable.m
% trans_trafficMatrix2flowTable
%
% Usage: [flowTable] = trans_trafficMatrix2flowTable(traff_trafficMatrix)
%
% Abstract: This function converts a "traffic matrix" into a "flow table".
% We translate the information about the traffic flows from the first
% format to the second one.
%
% Arguments:
% o In:
% traff_trafficMatrix(NxN): Average traffic flow offered between node
% pairs. The Traffic Matrix is a two-dimensional matrix with N (N:
% number of nodes) rows and N columns. An entry(s,d) means the average
% traffic flow from node 's' to node 'd', expressed in Gbps. The main
% diagonal is full of 0s.
% o Out:
% . flowTable(F,3): F-by-3 matrix. First column de ingress node, second
% the egress node, third the traffic offered = traffic carried in Gbps.
%
function [flowTable] = trans_trafficMatrix2flowTable(traff_trafficMatrix)
if (nargin==0), help trans_trafficMatrix2flowTable;return, end %help calling
if (nargin~=1), error('1: Incorrect number of arguments.'),end %Number of input arguments different of 1
[destinationNode sourceNode]=find(traff_trafficMatrix'>0);
numberOfFlows=length(sourceNode);
averageFlow=zeros(numberOfFlows,1);
for f=1:numberOfFlows,
averageFlow(f)=traff_trafficMatrix(sourceNode(f), destinationNode(f));
end
flowTable=[sourceNode destinationNode averageFlow];