?? rndtopo1d.m
字號:
%% function [C,netsize,D,Rm,Rd] = rndtopo1d(n,d,vard)%% Generates random topology and traffic matrix. Nodes are Poisson% distributed with average n on a line of size n. Distance between a flow's% source and destination is normal, with mean d and variance vard.%% Returns:% C - coordinates% netsize - size of the network% D - src-dst pairs% Rm{1:N} - MER routing matrix, where each line contains the explicit MER route corresponding % to the entry in D% Rd{1:N} - DIR routing matrix%function [C,netsize,D,Rm,Rd] = rndtopo1d(n,d,vard)% Draw N on random, from Poisson distribution with average n.% Uniformly distribute N nodes on the segment of size n.N = max(poissrnd(n),3); % if N = 2, there is an errorC(:,1) = sort(unifrnd(0,n,N,1));C(:,2) = zeros(N,1);netsize = [n,0];% lengths of flows are Gaussians with mean d and variance vard% however, we don't let length of a flow smaller than 1 and larger than N-1ddd = min(max(round(normrnd(d,vard,N,1)),ones(N,1)),N - 1 + zeros(N,1));D = mod((0:N-1)' + ddd,N)+1;% find MER routes and put in R (take minimum of lefthand and righthand routes)Rm = {};Rd = {};for i=1:N Rd{i} = [i,D(i)]; if dist(i,D(i),C) > symdist(i,D(i),C,netsize) Rm{i} = [max(i,D(i)):N,1:min(i,D(i))]; else Rm{i} = [min(i,D(i)):max(i,D(i))]; endend
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -