DAA Project Report
DAA Project Report
A PROJECT REPORT
Submitted by
BACHELOR OF ENGINEERING
IN
Chandigarh University
July-2024
BONAFIDE CERTIFICATE
Certified that this project report “Dijkstra's Algorithm for shortest route
finder.” is the bonafide work of “Kumar Aditya Shekhar, Arun Kumar, Aditya
Dwivedi” who carried out the project work under my/our supervision.
SIGNATURE SIGNATURE
In this project, we have made a real application of Dijkstra's Algorithm for route
optimization. Here, we emphasize on the efficiency and accuracy of it. Discuss its time
complexity O((V+E)logV), where V is number of vertices and E is the Number of
edges and explored how priority queues and adjacency lists improve the performance
of data structures. I also discussed limitations whereby the algorithm cannot have
negative edge weights. We here present multiple case studies showing how useful
Dijkstra's Algorithm is in real-world network routing applications in GPS systems and
transportation.
CHAPTER 1.
INTRODUCTION
Clients for a system that uses Dijkstra's Algorithm would most likely come from
industries or sectors where the shortest path between nodes or points is critical to
optimizing performance, reducing costs, or improving user experience. These clients
may include:
1. Companies involved in logistics and transportation
As e-commerce rises day by day and the expectation of the consumer becomes
faster delivery, one way to cope with this is the optimization of the routes for
delivery trucks. This makes Dijkstra's Algorithm an excellent tool for cutting down
fuel costs, delivering, and carbon emissions.
Real Time Issue: Urbanization contributes to heavy traffic congestion, and, today,
any modern GPS has to offer users real-time route indication that avoids traffic and
finds the quickest routes. Thus, by employing Dijkstra's Algorithm, it could
dynamically compute the shortest and most efficient paths possible so that
commuting times are minimized, thereby appreciably improving user satisfaction.
1. Inefficiency for large networks: Actually, most of the algorithms for determining
the shortest route available in today's world are inefficient for large-scale networks.
Thus, it causes increased processing time and overheads of computation. It would
be really time consuming to calculate the short path in case of large network by
manual or simple techniques.
Since large dynamic networks have associated many variables, including distances and
densities, among other cases, there is an urgent demand for a real-time solution toward the
finding of shortest paths within such networks. A problem for which Dijkstra's algorithm
systematically solves is finding the shortest route between two points within a weighted
graph, with appropriate possible adaptations toward such a process in relation to real-time
data and resource constraints.
To effectively design Dijkstra's Algorithm of a Shortest Route Finder the following should be
acquired.
1. Requirement Analysis: First of all, what should be done is to thoroughly analyze
all the requirements for the project. This will be an identity process involving the
kind of graph structure that best suits your application. Is it a directed graph? Is it
undirected? Further, is it either directed or undirected? Should it be weighted or
unweighted? Which input format: nodes, edges, weights? And finally, what
application would be a good fit: navigating a city, routing on a network, logistics
optimization.
2. Design and Algorithm Selection Choose an architecture for a system that will
implement Dijkstra's algorithm. Determine what representation you will use to
represent graph in code: adjacency matrix or adjacency list. Determine input/output
representation of shortest path calculation. Identify typical edge cases, such as an
isolated nodes, multiple shortest paths with same distance, at design time.
3. Implementation of the Data Structures: You would need the basic data structures
required for Dijkstra's algorithm, namely graph representation and priority queue
which is more or less a min-heap from which it will pick the smallest tentative
distance to go next. What is hard in implementing data structures to speed up
optimization when the size of the graph gets too big.
5. Input Graph and Visualization: The input should be interactive such that it will
graph it in. This can be done in three different ways: manual inputting, uploading a
file, or database connectivity. Apart from that, both the input graph and all the
computed shortest paths should be visualized so that the user has a more visible
view of the result. This requires using libraries for plotting graphs.
6. Testing and Validations: You should test the algorithm on lots of kinds of graphs-
they should be neither too small nor too big, neither too sparse nor too dense with a
number of different weight distributions. Besides that you should validate your
result by usage of known shortest paths in predefined test cases. Finally individual
components of the algorithm should be verified using unit tests in order to ensure
correct functioning; besides that integration tests should be used in order to verify
overall performance of the system.
7. Optimization and Scalability: Analyze the algorithm with regard to time and
space complexity. Improve the code or data structure's efficiency and eliminate
those redundant calculations. Discuss the possibilities for parallelization or a few
heuristics that will speed up results on graphs of gigantic size.
8. Documentation and Reporting: Complete documentation must describe the way
the algorithm works, data structures used, as well as instructions on accessing the
system. This should include all technical details in the implementation,
assumptions made, as well as instructions in conducting testing or the extension of
thesystem.
CHAPTER 2.
DESIGN FLOW/PROCESS
In addition, the complexity and time complexity of the algorithm are key. Dijkstra's
Algorithm works very well using a data structure in the form of a binary heap, that has a
time complexity of O((V+E)logV) where V is the number of vertices and E the edges. This
should be able to work with large graphs containing thousands and even millions of nodes,
and edges, most commonly found applications of route finding in real world, like road
networks or internet routing.
Another key specification is graph mutability, i.e., how the system responds to changing
dynamics within the graph. Real-time route-finding systems normally encounter changing
traffic conditions, road constructions, or accidents that involve nodes to be added/removed
or edge weights to be updated. The system needs to update the graph fairly efficiently
without needing to recompute paths from scratch.
The source-destination selection mechanism is a very important feature. Users must be able
to pick up the source and destination nodes conveniently by manual input, by geolocation,
or through a point-and-click interface on a graphical map. The system must also allow users
to compute not only the shortest path from one source to a specific destination but also for
multiple destinations or even for all-pairs shortest paths in more advanced route-planning
scenarios.
Relating to output, the system should intuitively be on the shortest path starting from the
nodes and edges used. The output should also include in-depth statistics, such as total
distance, number of nodes traversed, and time based on the edge weights taken from the
input graph.
Furthermore, the algorithm should scale well and have good error handling ability for a
number of large datasets and also unexpected inputs such as having negative edge weights
since Dijkstra's Algorithm does not have an explicit resolution of this kind of input. The
application will provide alternative routes which might get them there in less optimal ways
but possibly giving further advantages, such as routes through scenic areas and areas with
little traffic congestion.
In addition, it should also have modularity; therefore, the development can go for
integration with real-time sources such as traffic updates or even other algorithms including
A search in heuristic-based shortest path finding. This modularity ensures that the system is
extendable for future development.
In developing the system that would be used for Dijkstra's Algorithm for Shortest Route
Finder, several conditions had to be included for the same reasons of efficiency,
accuracy, and usability. The computing efficiency is critical, especially for large graphs
with a lot of nodes and edges. In its purest form, the time complexity of the algorithm is
O(V^2) with v being the number of vertices. This would need to be optimized, maybe by
using a priority queue, lowering the complexity down to (O(E + V log V)), where E is
the number of edges. Another limitation is memory usage, since storing large graphs
using adjacency matrices or lists will consume many resources when working with
dense networks. Furthermore, scalability must be considered; this system must support
graph sizes growing without significant performance degradation.
Further constraints on the routes would be posed like a minimization of latency for
dynamic networks. Implications on the User Interface: Design to aim for simplicity and
clarity. The user must be able to easily input start and destination points and must be able
to see the shortest path in friendly form, perhaps it is drawn on a map. It should also
handle edge cases, such as disconnected graphs or negative weight edges (though
Dijkstra's Algorithm is not even implemented to support negative weights in some
variation like the Bellman-Ford algorithm may be needed depending on the
functionality). Another design constraint can be that it has good error handling in that
any erroneous inputs like nodes are not existing be handled appropriately. Finally,
portability and compatibility are considered; in other words, the system should be able to
adapt to different platforms such as web and mobile and also integrate with other APIs
such as mapping services.
Overview
Dijkstra's algorithm happens to be the most used algorithm to determine the shortest path in
a graph from one node to other nodes. It can be applied both to weighted and unweighted
graphs but optimal for graphs with nonnegative weights. This paper presents its efficiency
as well as its constraint to its implementation in various applications, such as GPS
navigation systems, network routing protocols, and more.
Key Characteristics
• Input: A weighted graph with a start node.
• Output: Shortest path from starting node to all other nodes.
• Complexity: O(V^2) for adjacency matrix and O (E + V log V) using priority queue
(binary heap).
Limitations
• Negative Weights: Dijkstra's algorithm does not work for graphs having edges with
negative weights.
• Graph Density: It may go bad in highly dense graphs due to the overhead in the
priorityqueue.
Applications
• Navigation Systems: Shortest path finder from one place to another.
• Network Routing: Computation of paths for the transfer of data from one computer
to another in a network.
• Game Development: Pathfinding for NPCs in virtual environments.
2. Finalizing Features
While finalizing the features of a shortest route finder system, based on Dijkstra's
algorithm, the following must be considered:
Core Features
1. Graph Input:
• Allow users to input graphs manually or file uploads, e.g., JSON, CSV
• Support directed as well as undirected graph.
2. User Interface:
• Visual of the graph including shortest path found.
• Include controls to pick start and end nodes.
3. Pathfinding Execution:
• The Dijkstra algorithm is applied to calculate the shortest path.
• Provide real-time pathfinding as the graph is being edited in step-by-step.
4. Distance Metrics:
• Definition of Edges Weights: Ability to define weights of edges of any
nature, such as distance, time, cost, so that optimal paths can be found based
on the desired user criteria.
Advanced Features
1. Multi-Source/Destination:
• Allow a user to compute paths from multiple sources to multiple
destinations.
2. Graph Analysis Tools
• Tools for graph properties analysis, degree distribution, connectivity, and
average path length
3. Export Options:
• Allow users to export results and graph structure in various formats for
additional analysis
4. Real-time inputs
• Use real-time sources (e.g., traffic) to enhance the possibility of correctness
of routing computations
5. User Preferences
• It should allow the facility of setting preferences such as (avoid some
nodes/edges, prefer some paths).
Constraints
1. Performance
• It should be optimization of performance so that this algorithm works on
larger graphs with minimal latency
2. Usability
• The application user interface should intuitive and accessible to various
users of diverse technical backgrounds.
3. Compatibility:
• Compatibility across various platforms such as web, mobile, and so on will
expand reach for more end-users.
4. Scalability
• The application should be scalable in terms of a load of users and larger data
sets without the degradation of performance.
5. Security:
• Data protection measures should be there where the focus would be even
while dealing with real-world data integration.
2.4. Design Flow
CHAPTER 3.
RESULTS ANALYSIS AND VALIDATION
1. Introduction
2. Overview of Algorithm
The fundamental reason Dijkstra’s Algorithm works is that it maintains a list of nodes
which have not been visited ordered in the distance from the starting node, takes the
closest unvisited node, and revises the distances to its adjacent nodes. In short, those
are the steps of the algorithm:
Initialization, let all distances be infinity except for the source which shall be zero.
The implementation can either employ the priority queue or min-heap to retrieve the
node that has the least distance.
While there are still unvisited nodes, mark the last extracted node, and go to the next
neighbor involved.
Mark the node as processed and continue until no nodes remain unvisited.
3. Data Structures
• Representation of Graph: As stated before, graphs can be represented by a
matrix adjacency or objects’ adjacency properties. An adjacency list is
mainly employed in such representations as it reduces the storage
requirements for sparsity.
• Distance Array: an array (or dictionary) to keep track of the shortest
distance from source to each node.
• Priority Queue: a data structure to store nodes that allows retrieving the
node with the shortest distance in the most efficient way.
4. Implementation Steps
• Setup of the Graph: For this work, we used an adjacency list to construct
the graph. Alternatively, we could have used a dictionary data structure
with node IDs as keys and lists of edges along with weights as values.
class Graph {
public:
unordered_map<int, vector<pair<int, int>>> graph;
4.1. Conclusion
In conclusion, Dijkstra’s Algorithm stands out as the best method for identifying the
shortest path within a particular graph, especially a weighted one. Thanks to its well-
organized structure, which employs priority queues and the greedy algorithm design, this
method has been found suitable for optimum path search in different situations such as
navigating systems and network routing. In the course of this project, we illustrated the
ability of Dijkstra’s Algorithm to find the optimal path by taking into consideration the
edges weight without transgressing the distance between the nodes.
The practical application of the algorithm demonstrates the soundness of the theory, as well
as how one can utilize it in real situations. The algorithm has also proven its effectiveness
and flexibility by analyzing different types of graphs and input data, which enables it to
solve both small and large-scale problems.
In the future, research may delve into modifications of Dijkstra's Algorithm, for example, its
combination with other approaches in more advanced pathfinding situations, or it may
involve the use of machine learning to forecast traffic and improve routing in real time,
respectively. All in all, this project has emphasized the importance of Dijkstra’s Algorithm
in computer sciences and its application to tackle problems in the actual world efficiently.
REFERENCES