08-16-2017, 09:12 PM
ns2 simulation code for shortest path routing
When to use Shortest Path routing?
An algorithm that is designed essentially to find a path of minimum length between two specified vertices of a connected weighted graph
Architecture-of-Shortest-Path-Routing
General procedure to find out shortest path:
Initialize the array smallestWeight so that smallestWeight[u] = weights[vertex, u].
Set smallestWeight[vertex] = 0.
Find the vertex, v, that is closest to vertex for which the shortest path has not been determined.
Mark v as the (next) vertex for which the smallest weight is found.
For each vertex w in G, such that the shortest path from vertex to w has not been determined and an edge (v, w) exists, if the weight of the path to w via v is smaller than its current weight, update the weight of w to the weight of v + the weight of the edge (v, w).