?? rte2w.m
字號:
function W = rte2W(rte,f,h)
%RTE2W Converts routings to weight matrix.
% W = rte2W(rte,f,h)
% rte = routings; e.g., rte = {[1 2 3];[4 1]}, for routing 1-2-3 and 4-1
% f = flow
% h = handling cost (or equivalence factor)
%
% Example:
% rte = {[1 2 3 4],[2 4 1 2 3],[3 4 1 2 4]};
% f = [8 5 12];
% h = [3 2 1];
% W = rte2W(rte,f,h)
% Copyright (c) 1994-2006 by Michael G. Kay
% Matlog Version 9 13-Jan-2006 (http://www.ie.ncsu.edu/kay/matlog)
% Input Error Checking ****************************************************
error(nargchk(1,3,nargin));
if ~iscell(rte), rte = {rte}; end
if nargin < 2, f = ones(1,length(rte)); end
if nargin < 3, h = ones(1,length(rte)); end
if length(rte) ~= length(f(:))
error('Length of "f" must equal the number of routings.')
elseif length(rte) ~= length(h(:))
error('Length of "h" must equal the number of routings.')
end
% End (Input Error Checking) **********************************************
n = max([rte{:}]);
W = zeros(n);
for i = 1:length(rte)
for j = 1:length(rte{i})-1
W(rte{i}(j),rte{i}(j+1)) = W(rte{i}(j),rte{i}(j+1)) + f(i)*h(i);
end
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -