Data transfer operations is a crucial aspect in case of networking and routing. So efficient data transfer operations is a must need, with minimum hardware cost (Optical Cables, WDM Network components, Decoders, Multiplexers) and also in the minimum time possible. Thus, the need is to propose an algorithm that finds the shortest path between two nodes (source node and destination node).
Let’s see a completely new algorithm unlike Dijkstra’s Shortest Path or any other algorithm for finding Shortest Path.
Given a graph and two nodes (source node and destination node), find the shortest path between them.
Let’s Calculate the distance ratio for each link :
Distance of link AB [denoted by
d(AB)] = 10
Distance of link AC [denoted by
d(AC)] = 12
For link AB, Distance Ratio of AB = d(AB) / (d(AB) + d(AC))
For link AC, Distance Ratio of AC = d(AC) / (d(AB) + d(AC))
Given a graph and two nodes - 1. Find all the paths connecting the two nodes. 2. For each path calculate probability = (Distance Ratio). 3. After looping over all such paths, find the path for which the probability turns out to be minimum.
Input : Output : Shortest Path is [A -> B] Explanation : All possible paths are P1 = [A->B] P2 = [A->C->B] P3 = [A->D->B] total distance D = d(P1) + d(P2) + d(P3) = (3) + (2 + 5) + (4 + 3) = 17 distance ratio for P1 = d(P1) / D = 3/17 distance ratio for P2 = d(P2) / D = 7/17 distance ratio for P3 = d(P3) / D = 7/17 So the shortest path is P1 = [A->B] Input : Output : Shortest Path is [A -> B]
Let’s illustrate the algorithm with a 7-node network and find out the Probabilistic shortest path between
node 1 and
Below is the implementation :
Shortest Path is [1, 2, 5]
Advantage over common Shortest Path Algorithms :
Most of the shortest path algorithms are greedy algorithms. So its based on the fact that an optimal solution leads to a globally optimal solution. In most of the cases, due to greedy property, it may not always lead to an optimal solution. But using this algorithm, one can always guarantee an optimal solution and hence the accuracy is 100%.
Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.