0% found this document useful (0 votes)
5 views

Shortest Paths

The document discusses shortest paths in graph theory, emphasizing their significance in various applications such as navigation systems, networking, and logistics. It outlines several algorithms for finding shortest paths, including Dijkstra’s, Bellman-Ford, and Floyd-Warshall, along with their advantages, limitations, and time complexities. Additionally, it highlights the use of A* and Johnson’s algorithms for specific scenarios and real-world applications in transportation, logistics, and game development.

Uploaded by

rhems1995
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Shortest Paths

The document discusses shortest paths in graph theory, emphasizing their significance in various applications such as navigation systems, networking, and logistics. It outlines several algorithms for finding shortest paths, including Dijkstra’s, Bellman-Ford, and Floyd-Warshall, along with their advantages, limitations, and time complexities. Additionally, it highlights the use of A* and Johnson’s algorithms for specific scenarios and real-world applications in transportation, logistics, and game development.

Uploaded by

rhems1995
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 21

SHORTEST PATHS

DEFININTION AND IMPORTANCE TO


SHORTEST PATHS IN GRAPH THEORY
In graph theory, the shortest path between two nodes refers to the path
that minimizes the total edge weights (or simply the number of edges in
unweight graphs). Finding the shortest path is crucial for applications
that require optimal efficiency, such as route planning, network
optimization, and data routing.
APPLICATIONS IN REAL WORLD
NAVIGATION SYSTEMS
Algorithms like Dijkstra’s or A* are used in GPS systems to find the
fastest route between locations.
NETWORKING
Shortest path algorithms are used to determine the best routing paths
in computer networks.
LOGISTICS AND TRANSPORTATION
These algorithms help in optimizing delivery routes for minimizing travel
time or cost.
 Directed Graphs have edges that point in TYPES OF GRAPHS
one direction (e.g., a one-way street).
 Undirected Graphs have edges that do not
have a direction (e.g., a two-way street).
 Weighted Graphs have edges with values
that
 Unweighted Graphs assume that all edges
have the same cost. represent cost,
distance, or time.
DIJKSTRA’S ALGORITHM
Dijkstra’s algorithm finds the shortest path from a starting node to all
other nodes in a weighted graph with non-negative edge weights. It
works by iteratively selecting the closest node to the starting node and
updating the shortest path estimates for its neighbors.
STEPS FOR
 Initialize: Set the distance to the source IMPLEMENTING
node to 0 and all others to infinity.
DIJKSTRA’S ALGORITHM
 Visit: Choose the unvisited node with the
smallest distance.
 Update: For each neighbor of the current
node, if a shorter path is found, update its
distance.
 Repeat: Mark the current node as visited
and move to the next unvisited node with
the smallest tentative distance.
 Time Complexity Analysis and
Performance Considerations.
TIME COMPLEXITY ANALYSIS AND
PERFORMANCE CONSIDERATIONS
Using a simple array: O(V²), where V is the number of vertices.
Using a binary heap (priority queue): O((V + E) log V), where E is the number of
edges.
Dijkstra is efficient for graphs with non-negative weights but becomes inefficient
for graphs with negative weights.
 Limitation: It cannot handle
 negative edge weights, as it
Use Case: Route planning in
assumes the shortest path is
navigation apps.
always updated by visiting nodes
with lower cumulative costs.

USE CASES AND LIMITATIONS


BELLMAN-FORD ALGORITHM
The Bellman-Ford algorithm finds the shortest paths from a source node
to all other nodes in a graph, even with negative edge weights. It works
by relaxing all edges repeatedly, ensuring that the shortest path is
found after at most V-1 iterations (V is the number of vertices).
Advantages Disadvantages
 Handles negative edge weights  Slower than Dijkstra’s, with time
and detects negative weight complexity of O(V * E).
cycles.

COMPARISON WITH DIJKSTRA’S


ALGORITHM
TIME COMPLEXITY AND PRACTICAL
APPLICATIONS

Practical uses include financial models (detecting arbitrage) and routing


algorithms in networks with negative edge weights.
FLOYD-WARSHALL ALGORITHM
The Floyd-Warshall algorithm computes the shortest paths between all
pairs of nodes in a weighted graph. It is particularly useful for dense
graphs where finding the shortest path between each pair of nodes is
necessary.
 Initialization: Start with a matrix where STEPS FOR
each entry represents the shortest known IMPLEMENTING THE
path between two nodes. ALGORITHM AND ITS
 Iterate: For each intermediate node k, LOGIC
update the matrix by checking if a path
from node i to j through k is shorter than
the current known path.
 Repeat: This process is repeated for all
possible intermediate nodes.
 Time and Space Complexity Analysis
 Time Complexity: O(V³), where V is the
number of vertices.
 Space Complexity: O(V²), as the algorithm
requires a matrix to store all pairwise
distances.
OTHER SHORTEST PATH
TECHNIQUES
A SEARCH ALGORITHM
A* (A-star) is an informed search algorithm used in pathfinding. It uses
both the current path distance and a heuristic estimate of the remaining
distance to guide the search towards the goal efficiently
 Heuristics: A* uses heuristics to estimate
the cost from the current node to the
destination, improving performance over
algorithms like Dijkstra.
 Applications: Widely used in video games
for navigating characters and robots in
real-time.
 Johnson's Algorithm: Combining Dijkstra’s
and Bellman-Ford for Sparse Graphs.
Johnson’s algorithm finds the shortest paths between all pairs of nodes in a
sparse graph by:
• Using Bellman-Ford to reweight the edges so that all edge weights are non-
negative.
• Running Dijkstra’s algorithm from each vertex.
 Special Cases and Variants: Unweighted Graphs
and Bidirectional Search
 Unweighted Graphs: In unweighted graphs, the
shortest path can be found using a Breadth-First
Search (BFS), which operates in O(V + E).
 Bidirectional Search: This technique
simultaneously searches from both the start and
goal nodes, effectively reducing the search space.
 Real-World Applications of Shortest Path Algorithms
in Transportation, Logistics, and Game
Development
 Transportation: Algorithms are used in routing
vehicles or planning flight paths.
 Logistics: Helps optimize supply chain routes,
minimizing transportation costs.
 Game Development: Used for pathfinding in AI,
e.g., moving characters or objects in a game
environment.

You might also like