0% found this document useful (0 votes)
39 views15 pages

Daa PBL

Uploaded by

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

Daa PBL

Uploaded by

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

Project Report on

“City Navigation Map”


Submitted in Partial Fulfilment of the Requirement of the Degree
Of

Bachelor of Technology In
Computer Science and Engineering

Session 2024-2025

Subject Code – BCS-553


Subject Name – Design and Analysis of Algorithms

Project Guide
Er. Kratika Verma

Submitted by-
Aman (2200430100006)
Archi Agrawal (2200430100016)
Nikita (2200430100040)

Bundelkhand Institute of Engineering & Technology


Jhansi (U.P.) India- 284128

1 | Page
ACKNOWLEDGEMENT

It is our whole hearted pleasure to be indebted to various people, who directly


and indirectly contributed to the development of this work and who influenced
our thinking, behavior and acts during study.
First and foremost, we are thankful to Almighty God for making us capable and
confident. We are also very thankful to our parents for supporting and
motivating us at every stage of life.
I express my sincere gratitude to Prof. Sanjai Gupta (Head of Department
CSE) for providing us an opportunity to undergo this project as a part of the
curriculum.
We are thankful to our honorable faculty member of the subject “Design and
Analysis of Algorithm”, Er. Kritika Verma, for his support, cooperation, and
motivation provided to us during the making of this LAB.

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.

Prof. Sanjai Kumar Gupta Project


Guide:
Head Er.
Kratika Verma
Computer Science and Engineering

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.

Implementation of the Floyd-Warshall Algorithm


1. Problem Representation
The map is represented as a graph, where:
 Nodes: Represent cities or places.
 Edges: Represent roads or connections between these locations.
 Edge weights: Represent the distance or travel cost between two
nodes.
The goal is to find the shortest paths between all pairs of nodes.

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

Advantages of Using Floyd-Warshall


1. All-Pairs Shortest Paths: Computes shortest paths for all node pairs in a
single execution.
2. Handles Negative Weights: Supports negative edge weights, ensuring
flexibility in graph representations.
3. Simplicity: Easy to understand and implement.

Dynamic Programming Approach


The Floyd-Warshall algorithm inherently employs a dynamic programming
approach by systematically breaking down the problem into overlapping
subproblems and solving them iteratively. Here is how the dynamic programming
approach is applied:
1. State Representation: Let represent the shortest distance between
nodes and considering only the first nodes as intermediates.
2. Base Case: When, the shortest distance between and is the direct edge
weight, or infinity if no direct edge exists.
3. Recursive Relation: For each, update the shortest distance using
4. Final Solution: The result is stored in, where is the total number of
nodes.

Simplified Matrix Approach:


To optimize space, the algorithm uses a 2D array instead of a 3D array by
iteratively overwriting previous values.

Complexity Analysis of Floyd Warshall Algorithm:


 Time Complexity: O(V3), where V is the number of vertices in the graph
and we run three nested loops each of size V
 AuxiliarySpace: O(V2), to create a 2-D matrix in order to store the
shortest distance for each pair of nodes.

Illustration of Floyd Warshall Algorithm :

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:

CSS(Cascading Style Sheets)

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy