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.
[path]=RoutingPredRoute(pred,dist,i,j)
vector composed by the predecessor of each node in order to reach the source node.
vector composed by the distance between each node and the source node.
emission node.
destination node.
route between i and j.
RoutingPredRoute performs the path path between 2 network nodes i and j in respect with the predecessor vector pred generated by the Bellman-Ford algorithm, the Dijkstra's algorithm, BFS, DFS or the Prim's algorithm applied in i.
n=150;//network size l=1000;//network squared area side d=100;//Locality radius [g]=NtgLocalityConnex(n,l,d);//application of NtgLocalityConnex nf=length(g.node_x);//real network size nl=length(g.head);//quantity of network links [i,j]=Random_i_j(nf);//selection of the emission and destination nodes [dist,pred]=RoutingDijkstraO(g,i);//application of DijkstraO [path]=RoutingPredRoute(pred,dist,i,j)//application of PredRoute p=nodes_2_path(path,g);//display the path between i and j EC=ones(1,nl); EB=ones(1,nl); EC(p)=5; EB(p)=2; D=ones(1,nf); D(path)=3; g.node_border=D; g.edge_color=EC; g.edge_width=EB; show_graph(g); path | ![]() | ![]() |