Daa PBL
Daa PBL
Bachelor of Technology In
Computer Science and Engineering
Session 2024-2025
Project Guide
Er. Kratika Verma
Submitted by-
Aman (2200430100006)
Archi Agrawal (2200430100016)
Nikita (2200430100040)
1 | Page
ACKNOWLEDGEMENT
Project Group:
Aman (2200430100006)
Archi Agrawal (2200430100016)
Nikita (2200430100040)
2 | Page
BUNDELKHAND INSTITUTE OF ENGINEERING AND
TECHNOLOGY, JHANSI
CERTIFICATE
This is to certify that the project entitled “City Navigation Map” submitted by
Aman (2200430100006), Archi Agrawal (2200430100016), Nikita
(2200430100040) in the partial fulfilment of the requirement for the award of
Bachelor of Technology degree in Computer Science and Engineering at
Bundelkhand Institute of Engineering and Technology, Jhansi is an authentic work
carried out by them under any supervision and guidance.
To the best of my knowledge, the matter embodied in the project has not been
submitted to any other University Institute for award of any Degree of Diploma.
Introduction
City navigation plays a crucial role in modern urban planning, transportation
management, and travel optimization. With the increasing complexity of cities and
3 | Page
their interconnected places, finding the shortest paths between locations is
essential. This project, "City Navigation Map," uses the Floyd-Warshall algorithm
to compute the shortest paths between all pairs of nodes (cities or places) in a
weighted graph representing a city's map. The algorithm ensures efficiency and
accuracy in handling complex navigation scenarios with multiple locations and
interconnected roads.
The Floyd-Warshall algorithm is a dynamic programming technique widely used
to solve the all-pairs shortest path problem in weighted graphs. It operates with
both directed and undirected graphs and can handle positive and negative edge
weights (as long as there are no negative weight cycles).
The project aims to create a user-friendly web-based application that allows users to
input cities or places, view calculated shortest paths and navigate between
locations effectively. The backend implementation in Java ensures a robust and
efficient solution for calculating and visualizing these paths.
2. Algorithm Explanation
The Floyd-Warshall algorithm iteratively updates the shortest path matrix by
considering each node as an intermediate node. The core idea is:
For every pair of nodes and , check if a shorter path exists through an intermediate
node . If the path through is shorter, update the shortest path value.
Pseudocode:
Let dist[][] be the adjacency matrix representing the graph.
Number of nodes: n
// Initialize shortest paths as direct edges (or infinity if no direct edge
exists)
for (i = 0 to n-1):
for (j = 0 to n-1):
if i == j:
dist[i][j] = 0
4 | Page
else if edge(i, j) exists:
dist[i][j] = weight of edge(i, j)
else:
dist[i][j] = Infinity
// Update shortest paths using each node as an intermediate node
for (k = 0 to n-1):
for (i = 0 to n-1):
for (j = 0 to n-1):
if dist[i][j] > dist[i][k] + dist[k][j]:
dist[i][j] = dist[i][k] + dist[k][j]
return dist
5 | Page
Step 1: Initialize the Distance[][] matrix using the input graph such that
Distance[i][j]= weight of edge from i to j, also Distance[i][j] = Infinity if there is
no edge from i to j.
Step 2: Treat node A as an intermediate node and calculate the Distance[][] for
every {i,j} node pair using the formula:
= Distance[i][j] = minimum (Distance[i][j], (Distance from i to A) + (Distance from
A to j ))
= Distance[i][j] = minimum (Distance[i][j], Distance[i][A] + Distance[A][j])
6 | Page
Step 3: Treat node B as an intermediate node and calculate the Distance[][] for
every {i,j} node pair using the formula:
= Distance[i][j] = minimum (Distance[i][j], (Distance from i to B) + (Distance
from B to j ))
= Distance[i][j] = minimum (Distance[i][j], Distance[i][B] + Distance[B][j])
7 | Page
Step 4: Treat node C as an intermediate node and calculate the Distance[][] for
every {i,j} node pair using the formula:
= Distance[i][j] = minimum (Distance[i][j], (Distance from i to C) + (Distance
from C to j ))
= Distance[i][j] = minimum (Distance[i][j], Distance[i][C] + Distance[C][j])
Step 5: Treat node D as an intermediate node and calculate the Distance[][] for
every {i,j} node pair using the formula:
= Distance[i][j] = minimum (Distance[i][j], (Distance from i to D) + (Distance
from D to j ))
= Distance[i][j] = minimum (Distance[i][j], Distance[i][D] + Distance[D][j])
Step 6: Treat node E as an intermediate node and calculate the Distance[][] for
every {i,j} node pair using the formula:
8 | Page
= Distance[i][j] = minimum (Distance[i][j], (Distance from i to E) + (Distance
from E to j ))
= Distance[i][j] = minimum (Distance[i][j], Distance[i][E] + Distance[E][j])
Step 7: Since all the nodes have been treated as an intermediate node, we can
now return the updated Distance[][] matrix as our answer matrix.
CODE
9 | Page
HTML CODE:
10 | P a g e
JavaScript
11 | P a g e
12 | P a g e
13 | P a g e
Output
Reference
14 | P a g e
https://www.geeksforgeeks.org/floyd-warshall-algorithm-dp-16/
https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm
https://www.geeksforgeeks.org/finding-shortest-path-between-any-
two-nodes-using-floyd-warshall-algorithm/
https://developer.mozilla.org/en-US/
https://www.w3schools.com/js/
15 | P a g e