CS23D017 Dsa Project
CS23D017 Dsa Project
On
“Map Navigator (Dijkstra’s Algorithm)”
Submitted By:
Sachin H. Rahangdale (CS23D017)
Guided By:
Dr. Ravindra N. Jogekar
2023-2024
© S.B.J.I.T.M.R Nagpur 2023
i
S.B. JAIN INSTITUTE OF TECHNOLOGY MANAGEMENT &
RESEARCH, NAGPUR
(An Autonomous Institute, Affiliated to RTMNU, Nagpur)
SESSION 2023-2024
CERTIFICATE
This is to certify that the Project titled “Map Navigator (Dijkstra’s Algorithm)” is a bonafide
work of Sachin Rahangdale carried out for the partial fulfillment of course work of “Data
Structure & Algorithm”, 3rd Semester, Bachelor of Technology in Computer Science and
Engineering.
2
INDEX
CERTIFICATE
INDEX
LIST OF FIGURES
CHAPTER 1 INTRODUCTION
CHAPTER 2 METHODOLOGY
CHAPTER 3 TOOLS/PLATFORMS
4.1 ALGORITHM
4.2 FLOWCHART
4.3 MAP (GRAPH)
4.3 SOURCE CODE
5.1 OUTPUT
5.2 DISCUSSION
5.3 APPLICATION
CHAPTER 6 CONCLUSION
REFERENCES
7
LIST OF FIGURES
4.2.1 Flowchart
4.3.1 Map(Graph)
5.1.1 Output 1
5.1.2 Output 2
5.1.3 Output 3
5.1.4 Output 4
7
CHAPTER 1
INTRODUCTION
In the intricate landscape of map navigation, Dijkstra's algorithm emerges as a fundamental tool,
bearing the name of its visionary creator, Edsger W. Dijkstra. Esteemed for its proficiency in
determining the shortest path between two points on a graph, this algorithm finds application in
diverse scenarios, from urban exploration to intricate network routing. Its primary goal is to
minimize travel costs, making it an invaluable asset in the realm of efficient route planning.
The core of Dijkstra's algorithm lies in its graph representation, where locations are nodes and the
connections between them are edges. Each edge carries a weight, representing the cost or distance
between two locations. The initialization phase sets the foundation by assigning tentative distance
values to every node. Starting from the source node with a distance of 0, all other nodes are initially
marked with an infinite distance.
The algorithm's iterative exploration phase is where its power unfolds. It systematically selects
nodes with the smallest tentative distances, updating the distances of their neighbors by considering
the sum of the current distance and the edge weight. This meticulous process continues until the
destination node is reached, at which point the algorithm has successfully uncovered the shortest
path.
Dijkstra's algorithm boasts several advantages that contribute to its widespread use. It guarantees
optimality by maintaining a priority queue of nodes with the smallest tentative distances, ensuring
the reliability of the shortest path. Its versatility is evident in its applicability across various
domains, from GPS navigation systems guiding us through city streets to intricate network systems
determining the most efficient data routes. Moreover, the algorithm's implementation simplicity
renders it accessible for a broad range of applications.
2
CHAPTER 2
METHODOLOGY
Below is an outline of the various phases involved in managing a software project, from initiation to
closure, for the given codebase.
• Select a programming language that you are comfortable with. C, C++, Python, and Java are
common choices.
• Choose any additional tools or libraries you might need for graphical user interface (GUI), if
applicable.
• Represent the map as a graph where cities are nodes and roads are edges.
• Decide how to store city names and distances between cities.
• Choose appropriate data structures, such as arrays or matrices, to represent the graph.
• Write functions or methods to implement Dijkstra's algorithm for finding the shortest path
between two cities.
• Handle input parameters like source city, destination city, and the graph itself.
5. Input Handling:
6. Display Results:
• Print the distance and the path from the source to the destination.
• Display the path in a human-readable format, indicating each step of the journey.
• If you want a graphical interface, consider using GUI libraries or tools to create a more user-
friendly application.
• Display the map and highlight the path.
7
8. Error Handling:
• Implement error handling for invalid inputs, such as non-existent cities or incorrect user
entries.
9. Testing:
• Test your program with various inputs to ensure that it produces accurate results.
• Handle edge cases and unexpected scenarios.
10. Documentation:
• Provide clear documentation for your code, explaining the structure, functions, and how to
use your map navigation system.
• If possible, gather feedback from users and make improvements based on their suggestions.
13. Deployment:
• If applicable, package your application for deployment on the chosen platform (desktop,
web, mobile).
• Consider future enhancements, such as integrating with external APIs for live traffic data,
incorporating additional map features, etc.
7
CHAPTER 3
TOOLS/PLATFORMS
7
CHAPTER 4
DESIGN & IMPLEMENTATION
4.1 ALGORITHM
1. Initialize Graph:
2. Initialize Variables:
• Define arrays distance[], sptSet[], and parent[] to store distance, processed vertices, and
parent nodes, respectively.
• Set all distances to infinity, sptSet[] to false, and parent[] to -1.
4. Dijkstra's Algorithm:
5. Print Solution:
• Print the shortest distance from the source to the destination city.
• Print the path from the source to the destination city.
6. Input Handling:
7. Main Function:
7
4.2 FLOWCHART
7
4.3 MAP(GRAPH)
7
4.4 SOURCE CODE
#include <stdio.h>
#include <limits.h>
#include <string.h>
#define NUM_CITIES 6
#define MAX_NAME_LENGTH 20
return min_index;
}
int path[NUM_CITIES];
int pathLength = 0;
int main() {
char cities[NUM_CITIES][MAX_NAME_LENGTH] = {
"SB_JAIN", "Nagpur", "Gondia", "Pune", "Mumbai", "Wardha"
};
int graph[NUM_CITIES][NUM_CITIES] = {
// Adjacency matrix representing the distances between cities
// SB_JAIN Nagpur Gondia Pune Mumbai Wardha
{0, 268, 450, 142, 0, 0}, // SB_JAIN
{268, 0, 160, 0, 118, 146}, // Nagpur
{450, 160, 0, 600, 0, 0}, // Gondia
{142, 0, 600, 0, 0, 110}, // Pune
{0, 118, 0, 0, 0, 45}, // Mumbai
{0, 146, 0, 110, 40, 0} // Wardha
};
7
// Print the statement
printf("Enter your destination from SB_JAIN: ");
char destination[MAX_NAME_LENGTH];
scanf("%s", destination);
return 0;
}
7
CHAPTER 5
RESULT & DISCUSSION
5.1 OUTPUT
7
Fig 5.1.3 Output 3
7
5.2 DISCUSSION
1. Algorithmic Efficiency:
The choice of Dijkstra's algorithm for pathfinding in our map navigation system proved to be
effective. The algorithm systematically explores the network, ensuring that the shortest paths from
the source to all other locations are identified. However, it's essential to note that Dijkstra's
algorithm may not perform optimally in scenarios with negative edge weights or large graphs.
3. Graph Representation:
The map was represented as an adjacency matrix, offering a straightforward way to capture the
relationships between cities. While this representation suits our current needs, future iterations
might explore alternative representations, such as adjacency lists, especially for larger and more
complex maps.
4. Real-world Applications:
The successful implementation of Dijkstra's algorithm in our project highlights its real-world
applicability. The map navigation system can find practical use in scenarios such as daily
commuting, emergency response planning, and logistics, showcasing the versatility of the
algorithm.
8. Learning Outcomes:
The micro project served as an excellent learning opportunity. We gained insights into algorithmic
design, data representation, and user interface considerations. Challenges encountered during the
project provided valuable experiences that contribute to our growth as developers.
7
5.3 APPLICATION
Dijkstra's algorithm for map navigation has numerous applications in real-world scenarios. Here are
some common applications:
Dijkstra's algorithm is widely used in GPS navigation systems to find the shortest
path between a starting point and a destination. It helps drivers to navigate efficiently
by considering the current road conditions and traffic.
Dijkstra's algorithm is used in network routing protocols to find the shortest path for
data transmission between devices in computer networks. It ensures efficient data
flow through the network.
3. Telecommunications Networks:
For public transportation systems, such as buses or trains, Dijkstra's algorithm can be
applied to optimize routes, minimizing travel time and improving overall efficiency.
7. Urban Planning:
Urban planners use Dijkstra's algorithm to optimize traffic flow in cities. It helps in
designing efficient road networks and managing traffic congestion.
7
9. Resource Management in Cloud Computing:
In the design of utility networks, like gas pipelines or electrical grids, Dijkstra's
algorithm is used to determine the most cost-effective routes for connecting different
points.
In essence, any scenario where finding the shortest path between two points in a network is crucial
can benefit from the application of Dijkstra's algorithm. Its versatility makes it a fundamental tool in
various fields that involve optimizing routes and paths.
7
CHAPTER 6
CONCLUSION
In conclusion, the implementation of Dijkstra's algorithm in our map navigation project has proven
to be a valuable tool for finding the shortest paths between locations in a given network. Through
this project, we achieved the following:
1. Efficient Pathfinding:
2. User-Friendly Interface:
The user interface, designed to take input for source and destination cities, enhances
the usability of our map navigation system. Users can easily find the shortest path
and associated details by providing straightforward inputs.
3. Real-world Applications:
4. Graphical Representation:
The project lays the foundation for further enhancements and features. Integration
with real-time data, alternate path suggestions, and considerations for dynamic
factors like traffic could be explored to make the system more robust.
In conclusion, our map navigation project, powered by Dijkstra's algorithm, has successfully
demonstrated the effectiveness of this approach in solving real-world problems. The project serves
as a stepping stone for future developments in the realm of navigation systems and lays the
groundwork for further innovations in the field.
7
REFERENCE
[1] Book References :
MSBTE Data Structure Using C Book Tech Max Publication
[2] Link References :
https://www.wikipedia.org/
https://www.geeksforgeeks.org/dijkstras-shortest-path-algorithm-greedy-algo-7/
https://www.programiz.com/dsa/dijkstra-algorithm
https://www.freecodecamp.org/news/dijkstras-shortest-path-algorithm-visual-introduction/