Perform the path between two nodes of a tree.
[R] = NL_R_TreePathN2N(I,J,S,P)
Node.
Node.
Root.
Predecessor vector.
Path.
NL_R_TreePathN2N performs the path R between the two nodes I and J of the tree defined by its root node S and its predecessor vector P. The algorithm finds a common ancestor between the two paths from each node I and J towards the root node. Finally the two sub-paths are merged into a single path.
n=150;//network size L=1000;//network square area side dmax=100;//Locality radius [g]=NL_T_LocalityConnex(n,L,dmax);//generation of a topology in respect with the Locality method [r,nind]=NL_F_RandVectorNoRepl(1:length(g.node_x));//selection of the root node dw=5;//display parameter ind=1;//window index [ni,nind]=NL_F_RandVectorNoRepl(nind);//selection of ni [nj,nind]=NL_F_RandVectorNoRepl(nind);//selection of nj [go,v,pred]=NL_R_BFSPlot(g,r,dw,ind);//performance of the tree [p1]=NL_R_TreePathN2R(ni,r,pred)//path between node ni and the root [p2]=NL_R_TreePathN2R(nj,r,pred)//path between node nj and the root [path]=NL_R_TreePathN2N(ni,nj,r,pred)//application of NL_R_TreePathN2N | ![]() | ![]() |