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

DAA Project Report

path finder

Uploaded by

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

DAA Project Report

path finder

Uploaded by

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

Dijkstra's Algorithm for Shortest route finder

A PROJECT REPORT

Submitted by

Kumar Aditya Shekhar(22BCS10202)


Arun Kumar (22BCS10200)
Aditya Dwivedi(22BCS10306)

in partial fulfillment for the award of the degree of

BACHELOR OF ENGINEERING

IN

COMPUTER SCIENCE ENGINEERING

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

Geet Kiran Kaur


HEAD OF THE DEPARTMENT SUPERVISOR

Submitted for the project viva-voce examination held on

INTERNAL EXAMINER EXTERNAL EXAMINER


TABLE OF CONTENTS
List of Figures .............................................................................................................. i
List of Tables ..............................................................................................................ii
Abstract ......................................................................................................................iii
1.INTRODUCTION OF PROJECT. ....................................................................... 4
1.1. Client identification....................................................................................5
1.2. Identification of problem............................................................................6
1.3. Identification of task..................................................................................7
2.DESIGN FLOW/PROCESS..................................................................................8
2.1. Evaluation & Selection of Specifications/Features……..........................9
2.2. Design Constraint......................................................................................10
2.3. Analysis and Feature finalization subject to constraints………………..11
2.4 Design Flow……………………………………………………………….12
3. RESULTS ANALYSIS AND VALIDATION.......................................................13
3.1. Implementation of solution.... ..................................................................14
4. CONCLUSION AND FUTURE WORK................................................................15
4.1 Conclusion………..……………………………………………………….16
4.2 Future Work……………………………………………………………...17

References (If Any) ....................................................................................................18


List of Figures

Figure 3.1 ………………………………………………………………………………….

Figure 3.2 ………………………………………………………………………………….

Figure 4.1 …………………………………………………………………………….……


List of Tables

Table 3.1 ………………………………………………………………………………….


Table 3.2 ………………………………………………………………………………….
Table 4.1 …………………………………………………………………………….……
ABSTRACT

Dijkstra's Algorithm is one of the most fundamental graph traversal techniques


commonly applied to solve problems in finding a shortest path for both directed and
undirected graphs. This report explores the implementation and the application of
Dijkstra's Algorithm in finding the shortest route between two points in a graph. The
algorithm works on picking a minimum tentative distance out of all unvisited vertices,
and updating distances of their neighbors continues indefinitely. In the meanwhile, this
keeps on till shortest paths of all vertices get determined.

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

1.1. Client Identification/Need Identification/Identification of relevant


Contemporary issue

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.

2. Navigation and GPS Service Providers

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.

3. Telecommunications Network Providers

Contemporary Issue: Present Approach: To cater to the demand of high-speed


internet and reliable data transfer, present approach of optimizing network routing
by the telecom providers has to be minimum as regards delay in transferring the
data. Dijkstra's Algorithm forms the basis of finding the shortest path that is going
to help control the packet-switched networks to reduce latency while improving
service delivery.

4. Smart City Infrastructure Planners

Modern-day issue: The development of smart cities is an efficient management of


flow of traffic, public transport, and emergency services. In this scenario, shortest-
path algorithms such as Dijkstra's are very important to the management of traffic
control systems that help in reducing congestion and improving mobility for people
in urban areas.

1.2. Identification of Problem

Because of the importance of transportation, logistics, telecommunications, and network


routing in everyday life, the basic need nowadays is to find efficiently and accurately the
shortest route between two points in today's world. Routes are traditionally found, but
when criteria include real-time data, high scalability, and computational efficiency,
especially in large and complex networks, methods fall short.

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.

2. Dynamic Changes Network: Realistic networks, say road or communication


networks are often subject to dynamic changes as exemplified in traffic congestion,
closure of roads or new connections Many algorithms fail to work correctly in real
time while such changes are happening; they end up generating suboptimal route
calculations.

3. Resource Consumption-Many non-optimized algorithms consume very high


memory or processing resources, thus making them not feasible for the systems
with limited resources. Such systems include mobile devices or embedded systems.

4. Precision of Route Finding: Algorithms designed for route-finding may not


provide a solution; the route acquired may not necessarily be the shortest or most
efficient one that is possible at times resulting in delays or increasing
transportations or data transmission costs.

5. Challenges of Real-time Application : Application such as GPS navigation may


require algorithms to respond very quickly in real time. Algorithms that are too
slow or could not perform the update network data on the fly often lead to
inaccuracies in the routes suggested.

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.

1.3. Identification of Tasks

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.

4. Algorithm Implementation: Translate above process to write actual logic of


Dijkstra's algorithm such that proper initialization is done, updates in distance, and
tracing of path are performed during the process. As a matter of fact, to launch the
algorithm procedure you can use an initialization of distances; in each iteration
pick an unvisited node that has the smallest value for distance, then update
distances of neighbors and mark nodes as visited. Note the problem of
computational efficiency since this algorithm will run with the best time
complexity.

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

2.1. Evaluation & Selection of Specifications/Features

On the evaluation and selection of specifications and features in a project implementing


Dijkstra's Algorithm as a shortest route finder, critical factors include input format specified
as it would portray the graph as nodes or vertices and edges, in terms of weights like
distance or cost; support shall be available for both directed and undirected graphs for
different application scenarios.

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.

2.2. Design Constraints

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.

2.3. Analysis and Feature finalization subject to constraints

Analysis of Dijkstra's Algorithm

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

3.1. Implementation of solution

1. Introduction

Dijkstra's Algorithm is outlined within this chapter addressing implementation issues,


which is employed in determining the shortest path from a source node to all other
nodes within a graph. In addition, the implementation is done on directed or
undirected graphs with nonnegative edge weights.

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;

void add_edge(int u, int v, int weight) {


if (graph.find(u) == graph.end()) {
graph[u] = vector<pair<int, int>>();
}
if (graph.find(v) == graph.end()) {
graph[v] = vector<pair<int, int>>();
}
graph[u].push_back(make_pair(v, weight));
graph[v].push_back(make_pair(u, weight)); // For undirected graph
}

• Utilization of Dijkstra's Algorithm: It is possible to implement the


algorithm by using a priority queue so that the node with the least distance
can be extracted efficiently.

void dijkstra(vector<vector<iPair>>& graph, int src) {


int V = graph.size();
vector<int> dist(V, INT_MAX);

priority_queue<iPair, vector<iPair>, greater<iPair>> pq;


pq.push(make_pair(0, src));
dist[src] = 0;
while (!pq.empty()) {
int u = pq.top().second;
pq.pop();

for (auto& neighbor : graph[u]) {


int v = neighbor.first;
int weight = neighbor.second;

if (dist[v] > dist[u] + weight) {


dist[v] = dist[u] + weight;
pq.push(make_pair(dist[v], v));
}
}
}

cout << "Vertex Distance from Source" << endl;


for (int i = 0; i < V; ++i) {
cout << i << "\t\t" << dist[i] << endl;
}
}
CHAPTER 4.
CONCLUSION AND FUTURE WORK

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.

4.2. Future work

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

You might also like