Random direction mobility model.
[G,F,A] = NL_M_GraphRD(G,F,V,A,R)
Graph.
Graph handle.
Speed vector.
Angle vector.
Communication range.
NL_M_GraphRD simulates the random direction mobility model. The initial graph G is represented by its window handle F. Each node randomly selects a speed between . V gathers the selected speed for each node. Each node
follows its direction
with its constant speed
. In this model a node chooses a random direction and then travels to the border of the simulation area in that direction. On reaching the boundary it again selects another direction to follow.
n=100; cr=120; L=1000; nx=L*rand(1,n);//current x-coordinate of all nodes ny=L*rand(1,n);//current y-coordinate of all nodes //n=3; //cr=250; //nx=[100 200 300]; //ny=[100 300 100]; name='mobility'; t=[]; h=[]; [g]=NL_G_MakeGraph(name,n,t,h,nx,ny);//creation of a network graph [h,t]=NL_M_Locality(g.node_x,g.node_y,cr);//application of NL_M_Locality g.head=h; g.tail=t; i=1;//window index f=NL_M_Background(i,name);//application of NL_M_Background r=10;//radius c=1;//color t=0; f=NL_M_GraphDisplayUpdate(g,i,r,c); vm=10; v=vm*rand(1,n);//velocity for each node a=2*%pi*rand(1,n);//angle for each node for i=1:200 [g,f,a]=NL_M_GraphRD(g,f,v,a,cr);//application of NL_M_GraphRD end | ![]() | ![]() |