<< NL_R_PathsWithNi NL_R: Routing NL_R_Prim >>

NARVAL >> NL_R: Routing > NL_R_PredecessorRoute

NL_R_PredecessorRoute

Perform the shortest path between two network nodes in respect with the predecessor vector generated by the Bellman-Ford algorithm, the Dijkstra's algorithm, BFS, DFS or the Prim's algorithm.

Calling Sequence

[R] = NL_R_PredecessorRoute(P,D,I,J)

Arguments

P :

Vector composed by the predecessor of each node in order to reach the source node.

D :

Vector composed by the distance between each node and the source node.

I :

Emission node.

J :

Destination node.

R :

Route.

Description

NL_R_PredecessorRoute performs the path R between the two network nodes I and J in respect with the predecessor vector P generated by the Bellman-Ford algorithm, the Dijkstra's algorithm, BFS, DFS or the Prim's algorithm applied in I.

Examples

n=150;//network size
l=1000;//network squared area side
d=100;//Locality radius
[g]=NL_T_LocalityConnex(n,l,d);//generation of a topology
nf=length(g.node_x);//real network size
nl=length(g.head);//quantity of network links
[i,j]=NL_F_RandIntNiNj(nf);//selection of the emission and destination nodes
[dist,pred]=NL_R_Dijkstra(g,i);//Dijkstra algorithm
[path]=NL_R_PredecessorRoute(pred,dist,i,j)//application of NL_R_PredRoute
p=NL_G_Nodes2Path(path,g);//display the path between i and j
EC=ones(1,nl);//edge color
EBi=2;
EB=EBi*ones(1,nl);//edge width
EC(p)=5;
EB(p)=2*EBi;
Dbi=5;
D=Dbi*ones(1,nf);//node border
D(path)=Dbi*2;
g.node_border=D;
g.edge_color=EC;
g.edge_width=EB;
ind=1;//window index
[f]=NL_G_ShowGraphN(g,ind);//graph visualization

Report an issue
<< NL_R_PathsWithNi NL_R: Routing NL_R_Prim >>