Download as pdf or txt
Download as pdf or txt
You are on page 1of 26

Project-Based Learning Report on

“Transportation Network Optimization Using

Dijkstra's & Bellman Ford Algorithms”

Submitted by
Anjali Tiwari
(2100430130009)
Archit Srivastava
(2200430139001)
Pranshu Shekhar Shrivastav
(2200430139003)

For the award of degree of

Bachelor of Technology in Information Technology

BUNDELKHAND INSTITUTE OF ENGINEERING


AND TECHNOLOGY
(An Autonomous Institution)
Jhansi, Uttar Pradesh – 284128

Session – 2023-2024
CERTIFICATE OF DECLERATION
We hereby declare that this project-based learning report entitled “Transportation
Network Optimization Using Dijkstra's & Bellman Ford Algorithms” is an authenticated
work carried out by us for the partial fulfilment of this report in the Department of
Information Technology (Third Year). This work has not been submitted elsewhere for a
similar purpose except to the Department of Information Technology at Bundelkhand
Institute of Engineering and Technology, Jhansi, Uttar Pradesh – 284128.

Er. Kratika Verma


Department of Information Technology
Bundelkhand Institute of Engineering and Technology, Jhansi
ACKNOWLEDGEMENT
It is our great pleasure to acknowledge the assistance and contribution of the individuals
who co-operated with us to complete this assignment report successfully. First and
foremost, we wish to express our deep gratitude and thanks to Dr. Yashpal Singh, Head
of Department, Information Technology for their enthusiastic guidance and
encouragement throughout the work. It is for their patience, guidance and encouragement
at all time that this work has shaped up the way it is. We would like to thank everyone
who contributed their time and efforts to help in completing the project-based learning
report.
TABLE OF CONTENTS

1 Introduction I
2 Dijkstra’s Algorithm Implimentation II

3 Bellman Fords’s Implimentation III

4 Software requirements IV

5 Source code V-XVII

6 Outputs XVIII-XXII

7 Future Scope XXIII-XXIV

8 Conclusion XXV

9 References XXVI
Introduction

Graph theory serves as the backbone for solving complex real-world problems, and algorithms
like Dijkstra's and Bellman-Ford play a pivotal role in navigating these graphs. Dijkstra's algorithm
finds the shortest path in a graph with non-negative weights, while Bellman-Ford handles graphs with
potentially negative weights. This project delves into the implementation of these algorithms to explore
their applications and understand their underlying principles

The primary objectives of this project are twofold: to implement Dijkstra's and Bellman-Ford
algorithms and to comprehensively analyze their performance characteristics. By achieving these goals,
we aim to contribute to the understanding of these fundamental algorithms and provide a valuable
resource for developers and researchers in the field of graph theory.

The implementation of Dijkstra's and Bellman-Ford algorithms presented here forms the backbone of
a comprehensive solution for transportation network optimization. This project aims to address the
complexities involved in planning efficient routes, minimizing travel distances, and enhancing overall
network performance

The provided C++ code comprises two critical algorithms, Dijkstra's algorithm and the Bellman-Ford
algorithm, both of which are fundamental in the domain of graph theory and network optimization.
These algorithms are commonly employed for finding the shortest paths in weighted graphs, and in
this specific implementation, they are tailored for solving a transportation network problem involving
a set of stations.

5
Dijkstra's Algorithm Implementation

Dijkstra's algorithm
A cornerstone of graph theory, excels in scenarios where non-negative edge weights characterize
the graph. In our transportation network model, these edge weights represent the distances between
stations. The algorithm iteratively selects the station with the shortest distance from the source station,
gradually building a path to every other station. The modular design of the code facilitates easy
integration with diverse datasets, allowing it to be applied to varying transportation network structures.

Dijkstra's algorithm, developed by Edsger Dijkstra, is a widely used algorithm for finding the shortest
paths between nodes in a graph. The algorithm maintains a set of vertices whose shortest distance from
the source is known and continually expands this set until the shortest path to every vertex is determined

The time complexity of Dijkstra's algorithm is O(V^2) with an adjacency matrix and O((V + E) *
log(V)) with an adjacency list, where V is the number of vertices and E is the number of edges.

Key Highlights:
- Scalability:
The algorithm is scalable, making it suitable for networks of varying sizes, from small local transit
systems to expansive regional or national networks.

- Adaptability:
The code can be adapted to accommodate different metrics or constraints, such as travel time or cost
considerations.

6
Bellman-Ford Algorithm Implementation

The Bellman-Ford algorithm


It is a robust solution capable of handling graphs with both positive and negative edge weights.
This versatility is crucial for addressing scenarios where the transportation network may feature diverse
conditions or unforeseen challenges. The code incorporates a cycle-checking mechanism, allowing it to
identify and handle negative-weight cycles gracefully. This feature ensures the reliability of the results
by preventing the algorithm from falling into an infinite loop in the presence of certain graph
configurations.

The Bellman-Ford algorithm, named after Richard Bellman and Lester Ford, addresses the problem of
finding the shortest paths from a source vertex to all other vertices, even in the presence of negative
weight edges. The algorithm iteratively relaxes all edges, ensuring that the shortest paths are gradually
refined.

The time complexity of the Bellman-Ford algorithm is O(V * E), where V is the number of vertices and
E is the number of edges.

Key Highlights:
- Robustness:

The algorithm's ability to handle negative edge weights adds robustness to the solution, making it
suitable for real-world scenarios with dynamic conditions

- Cycle Detection:

The cycle-checking mechanism prevents the algorithm from being misled by negative-weight cycles,
enhancing the accuracy of the computed shortest paths.

7
Software Requirements

The software requirements for the "Transportation Network Optimization Using Dijkstra's &
Bellman-Ford Algorithms" project, aimed at enhancing transportation efficiency through algorithmic
optimization, can be multifaceted. Given the complexity of managing transportation networks, these
requirements encompass both algorithmic implementations and supporting technologies. Below is a
list of key software components and technologies that may be pivotal for the successful development
and implementation of this project:

1. Operating System:
- C++ is platform-independent, so the project can be developed and run on Windows, macOS, or
Linux-based systems.

2. Development Environment:
- Choose a C++-friendly integrated development environment (IDE) such as Visual Studio, Code.

3. Compiler:
- Installed a C++ compiler such as GCC (GNU Compiler Collection) compiler.

4. Version Control:
- Git for version control to manage and track changes in the source code.

5. Documentation Tools:
-Choose a documentation tool compatible with C++, such as Doxygen, to generate documentation
from source code comments.

8
Source code
Dijkstra Code
#include<iostream>

#include<string.h>

#include<climits>

using namespace std;

#define INF 999

int mindistance(int distance[],bool stat[])

int minimum=INT_MAX,ind;

for(int k=0;k<56;k++)

if(stat[k]==false && distance[k]<=minimum)

minimum=distance[k];

ind=k;

return ind;

void dijkstra(int graph[56][56],int source, string stations[55])

int distance[56];

bool stat[56];

for(int k=0;k<56;k++)

distance[k]=INT_MAX;

stat[k]=false;

9
}

distance[source]=0;

for(int k=0;k<56;k++)

int m=mindistance(distance,stat);

stat[m]=true;

for(int k=0;k<56;k++)

if(!stat[k] && graph[m][k] && distance[m]!=INT_MAX && distance[m]+graph[m][k]<distance[k])

distance[k]=distance[m]+graph[m][k];

cout<<"Minimum Number of Stations from "<<stations[source]<<" To every station"<<endl;

for(int k=0;k<56;k++)

cout<<"Minimum Stations from "<<stations[source]<<" To "<<stations[k]<<" are "<<distance[k]<<endl;

int main()

int graph[56][56]={

//same as in bellman ford implementation;

};

int source

string stations[56]={

//(same as in bellman ford implementation)

};

cout<<"Enter the source station"<<endl;

for(int i=0;i<56;i++)

10
{

cout<<"Enter "<<i<<" for "<<stations[i]<<endl;

cin>>source;

dijkstra(graph,source,stations);

return 0;

Bellman-Ford Code

#include <iostream>

#include <string.h>

#include <climits>

using namespace std;

#define INF 999

// Function to implement Bellman-Ford algorithm

void bellmanFord(int graph[56][56], int source, string stations[55]) {

int distance[56];

// Step 1: Initialize distances from the source to all vertices as INFINITE

for (int i = 0; i < 56; i++) {

distance[i] = INF;

11
// Mark the source vertex

distance[source] = 0;

// Step 2: Relax all edges |V| - 1 times

for (int i = 0; i < 55; i++) {

for (int u = 0; u < 56; u++) {

for (int v = 0; v < 56; v++) {

if (graph[u][v] && distance[u] != INF && distance[u] + graph[u][v] < distance[v]) {

distance[v] = distance[u] + graph[u][v];

// Step 3: Check for negative-weight cycles

for (int u = 0; u < 56; u++) {

for (int v = 0; v < 56; v++) {

if (graph[u][v] && distance[u] != INF && distance[u] + graph[u][v] < distance[v]) {

cout << "Graph contains negative weight cycle" << endl;

return;

// Print the distances

12
cout << "Minimum Number of Stations from " << stations[source] << " To every station" << endl;

for (int i = 0; i < 56; i++) {

cout << "Minimum Stations from " << stations[source] << " To " << stations[i] << " are " << distance[i] <<
endl;

int main() {

int graph[56][56] = {{0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,


0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

{1, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 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ratganj","Durgapuri","CCS International Airport","IT Chauraha","Indira
Nagar","Hussainganj","Lekhraj Market","Krishna Nagar","KD Singh Babu Stadium","Munshi
Pulia","Mawaiya","Lucknow University","Transport Nagar","Singar
Nagar","Sachivalaya","Aishbagh","Daliganj","Sitapur Road","Ekana","KGMU","PGI","Rajajipuram","Civil
lines","Kaiserbagh","Aminabad","Gomti Nagar","Sadar Bazar","High Court","Aliganj","Vikas Nagar","Lucknow
City","Dilkush","Vishwas Khand","PAC Colony","Chinhat","Balmiki Nagar","Patel Nagar","Vikas
Khand","Bijaipur","Lalkuan","Ghosiyana","MathuraNagar","Hudson Lines","Bargawan","Ram
Nagar","Deopur","Indirapuram","Telibagh","Jalalpur","Jankipuram"};

16
int source; // Set your desired source station index

cout<<"Enter the source station"<<endl;

for(int i=0;i<56;i++)

cout<<"Enter "<<i<<" for "<<stations[i]<<endl;

cin>>source;

bellmanFord(graph, source, stations);

return 0;

17
Output

Graph Representation

18
Output 1

19
Output 2

20
Output 3

21
Output 4

22
Future Scope

The implementation of Transportation Network Optimization using Dijkstra's and


BellmanFord Algorithms lays a solid foundation for further enhancements and expansions. The
project's future scope encompasses several avenues for improvement and extension:

Algorithm Refinements
Explore advanced variants and optimizations of Dijkstra's and Bellman-Ford algorithms to further
improve efficiency and adaptability. Consider integrating parallel processing techniques for faster
computation, especially beneficial for large-scale transportation networks.

Real-Time Integration
Investigate the integration of real-time data feeds, such as traffic updates, road closures, or variable
transportation costs, to enhance the algorithms' responsiveness and provide more accurate
optimization results.

Multi-Objective Optimization
Extend the project to support multi-objective optimization, where factors like time, cost, and
environmental impact are considered simultaneously. This expansion would cater to a broader range
of decision-making scenarios.

Machine Learning Integration


Explore the integration of machine learning algorithms to predict transportation network changes
dynamically. This adaptive approach could lead to more proactive optimization and efficient
decisionmaking.

User friendly Interface


Develop user-friendly interfaces and visualization tools to enable easy interaction with the
optimization system. Incorporate features like intuitive dashboards and reports to assist transportation
planners and decision-makers.

23
Cloud-Based Deployment
Consider migrating the system to a cloud-based infrastructure for improved scalability and
accessibility. Cloud deployment facilitates seamless integration with other services and ensures
efficient resource utilization.

Global Network Optimization


Extend the project to handle global transportation networks, accommodating cross-border logistics
and international trade considerations. This would involve addressing diverse geographical and
regulatory challenges.

Collaborative Decision Support


Implement collaborative decision support features, allowing multiple stakeholders to contribute to the
optimization process. This could include collaboration between transportation agencies, businesses,
and local authorities.

24
Conclusion

In conclusion, the implementation of Dijkstra's and Bellman-Ford algorithms has been a


journey into the intricate world of graph theory and algorithmic optimization. Dijkstra's algorithm,
renowned for its efficiency in non-negative weighted graphs, showcased its prowess in scenarios
demanding swift pathfinding. On the other hand, the Bellman-Ford algorithm, designed to handle
graphs with potentially negative weights, exhibited resilience in diverse settings. Rigorous testing and
performance analysis underscored the reliability of our implementations, providing a robust
foundation for further exploration.

The comparative analysis brought to light the nuanced trade-offs between these algorithms,
emphasizing the need for careful consideration based on specific use cases. The project's insights extend
beyond the confines of theoretical algorithms, offering practical implications for real-world
applications. This endeavor not only deepened our comprehension of these fundamental algorithms but
also sparked contemplation on their adaptability and scalability in addressing complex problems.
Looking forward, the lessons learned and challenges faced pave the way for future refinements and
extensions, ensuring the continued relevance of Dijkstra's and Bellman-Ford algorithms in the
everevolving landscape of computational problem-solving.

25
References

• https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://dev.mysql.c
om/doc/refman/8.0/en/what-is-
mysql.html&ved=2ahUKEwiJq9b3jeeCAxU01DQHHdpdBq8QFnoECD0QAQ&usg=AOvVa
w1S4AT_ItA8MuOXEz-E93VF
• https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://www.ibm.c
om/docs/en/zos-basic-skills%3Ftopic%3Dzos-what-is-database-management-
system&ved=2ahUKEwimlNaRjueCAxW4sVYBHSg1C3EQFnoECBwQAQ&usg=AOvVaw1
0y21zu5hAwEUG6-Xhvj2j
• https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://docs.devart.
com/studio-for-sql-server/getting-started/connect-to-sql-
database.html&ved=2ahUKEwih6bSnjueCAxVhk1YBHfRCCjwQFnoECB0QAQ&usg=AOv
Vaw3IG4GvEf7pM99emS8GUQcq
• https://www.google.com/url?sa=t&source=web&rct=j&opi=89978449&url=https://www.oracle
.com/in/database/what-is-
database/&ved=2ahUKEwi0nejwjueCAxVutlYBHURBBcQFnoECDkQAQ&usg=AOvVaw2OS
CB7rUGCTcKlUqw4Hsc5
• https://www.javatpoint.com/what-is-database

26

You might also like