
- Data Comm & Networks Home
- DCN - Overview
- DCN - What is Computer Network
- DCN - Uses of Computer Network
- DCN - Computer Network Types
- DCN - Network LAN Technologies
- DCN - Computer Network Models
- DCN - Computer Network Security
- DCN - Components
- DCN - Connectors
- DCN - Switches
- DCN - Repeaters
- DCN - Gateways
- DCN - Bridges
- DCN - Socket
- DCN - Network Interface Card
- DCN - NIC: Pros and Cons
- DCN - Network Hardware
- DCN - Network Port
- Computer Network Topologies
- DCN - Computer Network Topologies
- DCN - Point-to-point Topology
- DCN - Bus Topology
- DCN - Star Topology
- DCN - Ring Topology
- DCN - Mesh Topology
- DCN - Tree Topology
- DCN - Hybrid Topology
- Physical Layer
- DCN - Physical Layer Introduction
- DCN - Digital Transmission
- DCN - Analog Transmission
- DCN - Transmission media
- DCN - Wireless Transmission
- DCN - Transmission Impairments
- DCN - Multiplexing
- DCN - Network Switching
- Data Link Layer
- DCN - Data Link Layer Introduction
- DCN - Data Link Control & Protocols
- DCN - RMON
- DCN - Token Ring Network
- DCN - Hamming Code
- DCN - Byte Stuffing
- DCN - Channel Allocation
- DCN - MAC Address
- DCN - Cyclic Redundancy Checks
- DCN - Error Control
- DCN - Flow Control
- DCN - Framing
- DCN - Error Detection & Correction
- DCN - Error Correcting Codes
- DCN - Parity Bits
- Network Layer
- DCN - Network Layer Introduction
- DCN - Network Addressing
- DCN - Routing
- DCN - Internetworking
- DCN - Network Layer Protocols
- DCN - Routing Information Protocol
- DCN - Border Gateway Protocol
- DCN - OSPF Protocol
- DCN - Network Address Translation
- DCN - Network Address Translation Types
- Transport Layer
- DCN - Transport Layer Introduction
- DCN - Transmission Control Protocol
- DCN - User Datagram Protocol
- DCN - Congestion Control
- DCN - TCP Service Model
- DCN - TLS Handshake
- DCN - TCP Vs. UDP
- Application Layer
- DCN - Application Layer Introduction
- DCN - Client-Server Model
- DCN - Application Protocols
- DCN - Network Services
- DCN - Virtual Private Network
- DCN - Load Shedding
- DCN - Optimality Principle
- DCN - Service Primitives
- DCN - Services of Network Security
- DCN - Hypertext Transfer Protocol
- DCN - File Transfer Protocol
- DCN - Secure Socket Layer
- Network Protocols
- DCN - ALOHA Protocol
- DCN - Pure ALOHA Protocol
- DCN - Sliding Window Protocol
- DCN - Stop and Wait Protocol
- DCN - Link State Routing
- DCN - Link State Routing Protocol
- Network Algorithms
- DCN - Shortest Path Algorithm
- DCN - Routing Algorithm
- DCN - Leaky Bucket Algorithm
- Wireless Networks
- DCN - Wireless Networks
- DCN - Wireless LANs
- DCN - Wireless LAN & IEEE 802.11
- DCN - IEEE 802.11 Wireless LAN Standards
- DCN - IEEE 802.11 Networks
- Multiplexing
- DCN - Multiplexing & Its Types
- DCN - Time Division Multiplexing
- DCN - Synchronous TDM
- DCN - Asynchronous TDM
- DCN - Synchronous Vs. Asynchronous TDM
- DCN - Frequency Division Multiplexing
- DCN - TDM Vs. FDM
- DCN - Code Division Multiplexing
- DCN - Wavelength Division Multiplexing
- Miscellaneous
- DCN - Shortest Path Routing
- DCN - B-ISDN Reference Model
- DCN - Design Issues For Layers
- DCN - Selective-repeat ARQ
- DCN - Flooding
- DCN - E-Mail Format
- DCN - Cryptography
- DCN - Unicast, Broadcast, & Multicast
- DCN - Network Virtualization
- DCN - Flow Vs. Congestion Control
- DCN - Asynchronous Transfer Mode
- DCN - ATM Networks
- DCN - Synchronous Vs. Asynchronous Transmission
- DCN - Network Attacks
- DCN - WiMax
- DCN - Buffering
- DCN - Authentication
- DCN Useful Resources
- DCN - Quick Guide
- DCN - Useful Resources
Shortest Path Algorithm in Computer Networks
In computer networks, the shortest path algorithms aim to find the optimal paths between the network nodes so that routing cost is minimized. They are direct applications of the shortest path algorithms proposed in graph theory.
Explanation
Consider that a network comprises of N vertices (nodes or network devices) that are connected by M edges (transmission lines). Each edge is associated with a weight, representing the physical distance or the transmission delay of the transmission line. The target of shortest path algorithms is to find a route between any pair of vertices along the edges, so the sum of weights of edges is minimum. If the edges are of equal weights, the shortest path algorithm aims to find a route having minimum number of hops.
Common Shortest Path Algorithms
Some common shortest path algorithms are
-
Bellman Fords Algorithm
-
Dijkstras Algorithm
-
Floyd Warshalls Algorithm
The following sections describes each of these algorithms.
Bellman Ford Algorithm
Input A graph representing the network; and a source node, s
Output Shortest path from s to all other nodes.
-
Initialize distances from s to all nodes as infinite (); distance to itself as 0; an array dist[] of size |V| (number of nodes) with all values as except dist[s].
-
Calculate the shortest distances iteratively. Repeat |V|- 1 times for each node except s
-
Repeat for each edge connecting vertices u and v
-
If dist[v] > (dist[u] + weight of edge u-v), Then
-
Update dist[v] = dist[u] + weight of edge u-v
-
-
-
-
The array dist[] contains the shortest path from s to every other node.
Dijkstras Algorithm
Input A graph representing the network; and a source node, s
Output A shortest path tree, spt[], with s as the root node.
Initializations
-
An array of distances dist[] of size |V| (number of nodes), where dist[s] = 0 and dist[u] = (infinite), where u represents a node in the graph except s.
-
An array, Q, containing all nodes in the graph. When the algorithm runs into completion, Q will become empty.
-
An empty set, S, to which the visited nodes will be added. When the algorithm runs into completion, S will contain all the nodes in the graph.
-
Repeat while Q is not empty
-
Remove from Q, the node, u having the smallest dist[u] and which is not in S. In the first run, dist[s] is removed.
-
Add u to S, marking u as visited.
-
For each node v which is adjacent to u, update dist[v] as
-
If (dist[u] + weight of edge u-v) < dist[v], Then
-
Update dist[v] = dist[u] + weight of edge u-v
-
-
-
-
The array dist[] contains the shortest path from s to every other node.
Floyd Warshall Algorithm
Input A cost adjacency matrix, adj[][], representing the paths between the nodes in the network.
Output A shortest path cost matrix, cost[][], showing the shortest paths in terms of cost between each pair of nodes in the graph.
-
Populate cost[][] as follows:
-
If adj[][] is empty Then cost[][] = (infinite)
-
Else cost[][] = adj[][]
-
-
N = |V|, where V represents the set of nodes in the network.
-
Repeat for k = 1 to N
-
Repeat for i = 1 to N
-
Repeat for j = 1 to N
-
If cost[i][k] + cost[k][j] < cost[i][j], Then
-
Update cost[i][j] := cost[i][k] + cost[k][j]
-
-
-
-
-
The matrix cost[][] contains the shortest cost from each node, i , to every other node, j.