rndtopo1d.m

来自「UWB 功率控制 容量 Main Matlab script is in」· M 代码 · 共 45 行

M
45
字号
%% 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 + =
减小字号Ctrl + -
显示快捷键?