0% found this document useful (0 votes)
110 views9 pages

Design and Implementation of Shortest Path System Using Dijkstra'S Algorithm

This document describes the design and implementation of a shortest path finding system using Dijkstra's algorithm in Python. The system uses two CSV files to store location data and distances between places. It allows users to select a source and destination and displays the shortest route between them. Dijkstra's algorithm is used to calculate the shortest distances and the route is highlighted on a map. The system was tested on example routes within Yangon to demonstrate finding the optimal path between locations.

Uploaded by

Tay Zar Naung
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)
110 views9 pages

Design and Implementation of Shortest Path System Using Dijkstra'S Algorithm

This document describes the design and implementation of a shortest path finding system using Dijkstra's algorithm in Python. The system uses two CSV files to store location data and distances between places. It allows users to select a source and destination and displays the shortest route between them. Dijkstra's algorithm is used to calculate the shortest distances and the route is highlighted on a map. The system was tested on example routes within Yangon to demonstrate finding the optimal path between locations.

Uploaded by

Tay Zar Naung
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/ 9

CHAPTER 4

DESIGN AND IMPLEMENTATION OF


SHORTEST PATH SYSTEM USING DIJKSTRA’S ALGORITHM

This chapter describes design and implementation of the shortest path finding
system. This system is intended to give shortest route information based on the
provided source and destination by using Dijkstra’s algorithm. This system is
implemented using python programming language. This system consists of two parts
which are coordinating places on the map and calculating shortest distance between
two places.

4.1. Shortest Path System Design


In placing a graph, there are two csv files: LatLon.csv and Distance.csv files.
The LatLon.csv file is to locate vertices with x-coordinate and y-coordinate on map
and the Distance.csv file is to calculate shortest distances between two places. Firstly,
latitudes and longitudes are collected from openstreetmap.org and stored in
LatLon.csv. As shown in Figure 4.1, the distances between them are pre-calculated
using Haversine formula and stored to distance.csv.

Read input from LatLon.csv

Calculate distances using Haversine

Store distances to Distance.csv

Figure 4.1. Block Diagram for Predefined System


33

In Figure 4.2, the system’s goal is to compute the shortest path between any
places that are provided in graph. A user has to select source and destination and then
shortest distance is evaluated using Dijkstra’s algorithm. After the shortest distance
between desired latitudes and longitudes has been determined, the connection across
the shortest path will be showed on map with a highlighted red color line.

Choose Source and Destination

Find the shortest distance using


Dijkstra’s Algorithm

Show the route on map

Figure 4.2. Block Diagram for System Design

The places in Yangon City are disposed as the nodes and the distance between
these places is disposed as the edge in the graph. These distance and places are
referenced using Google Map. The LatLon.csv file accepts place’s name, x-coordinate
and y-coordinate. This is shown in Figure 4.3.

Start

Read the input from LatLon.csv file

Yes No
Length !=
3?

Add vertex to a graph with


Invalid line in vertex file
x, y-coordinate

End

Figure 4.3. Flow Chart for Input of Graph from LatLon.csv File
34

The Distance.csv file accepts the names of two places and the distance
between these places. If the input for these files is not equal length of three, these
inputs are invalid. This is also shown in Figure 4.4. For example, if user inputs the
start place, end place, shortest distance between the two places is captured from
Distance.csv file. This system is placed on the map using graphic of Python
programming based on these inputs. LatLon.csv is read from Python pandas library
and Distance.csv is written out using Python csv library.

Start

Read the input from Distance.csv file

Yes Length != No
3?

Add edge between two


Invalid line in edge file
vertices in a graph

End

Figure 4.4. Flow Chart for Input of Graph from Distance.csv File

4.2. System Implementation using Dijkstra’s algorithm


The detailed descriptions of the shortest path finding system are described in
this section. The step by step procedures are presented by using web based application
to choose the shortest route.
In this thesis, the system is implemented to help where the shortest path is
located using Dijkstra’s algorithm. It has been provided with data and some codes for
graphical user interface (GUI), which generates a map of some places in the Yangon
city and the different connections between them. Users can only check the shortest
route that will definitely make travel arrangement easy and efficient. This system is
35

basically targeted to users and will save the travelling time. Dijkstra’s algorithm has
been used to solve the problem.
This system is implemented by Python programming language. Dijkstra’s
algorithm helps to find the shortest path between a source place and destination place
in a graph. The algorithm is ubiquitous. For example, it is used in computer
networking where it ascertains the shortest path between the source router and other
routers in the network. Also, each time is navigating via google maps, complex
algorithms based on Dijkstra’s algorithm are being used to provide with the best
route.
Figure 4.5 is an illustration of map development where points are generated
from LatLon.csv. A user can find the shortest path of any source and destination
located in LatLon.csv.

Figure 4.5. Map Development for Shortest Path System


36

In this first step, the user has to choose source and destination and click search
button in main frame to continue the program simulation and the program window is
displayed in Figure 4.6. Once the user submits to search button, the map will be
displayed immediately to browser.

Figure 4.6. Cover Window for the System

4.3. Data Entry with Distance between Two Places


In this system, the places in the Yangon City are disposed in the csv file with
x-coordinate and y-coordinate to locate on map. The starting place, ending place and
the distance between two places are also disposed on map. As shown in Figure 4.7,
the LatLon.csv file consists of the name of some places in Yangon city with x-
coordinate and y-coordinate values. These values are used in arrangement to dispose
the places on the map form a csv file because Dijkstra’s algorithm is used in graph
theory. So, the places are disposed as vertices on the map form for the first step of
finding shortest path system using Dijkstra’s algorithm.
37

Figure 4.7. The Sample Places with X-coordinate and Y-coordinate

The Distance.csv file consists of the name of places and the distance between
two places. This csv file contains the famous places that are well-known people in
Yangon City. The distance.csv file is listed as direct connections between pairs of
places as shown in Figure 4.8.

Figure 4.8. The Sample Distance Among Places


38

4.4. Training Panel of Shortest Path System


The famous places in the city are disposed on the map and the highlighted line
of the shortest route will be shown as a result. The start place and end place are inputs
from the LatLon.csv file. These inputs are selected from the box in Python GUI. The
main panel consists of two selected boxes and one button.
In this process, the user has to choose the start place and the end place from
the box and calculate the shortest path between two places. The result will show in
result panel with colored line.
To calculate shortest path between Hledan and Sule, the user selects start place
(Hledan) and end place (Sule) from the combo box of the graph. And then, the user
clicks search button to compute the shortest path. This process is displayed in Figure
4.9. In this Figure, the shortest path between Hledan and Sule using Dijkstra’s
algorithm is displayed with highlighted line as an example. The total distance between
two places is also calculated and displayed on the map.

Figure 4.9. The Shortest Path between Hledan and Sule


39

As the another example, the shortest distance between Myanmar Plaza and A
Shae Phat Mote of Shwedagon Pagoda is calculated using Dijkstra’s algorithm and
displayed with highlighted line. The result is shown in Figure 4.10.

Figure 4.10. The Shortest Path between Myanmar Plaza and A Shae Phat Mote

4.5. Experimental Result of Dijkstra’s Algorithm


While analysing the result for the specific shortest path problem solving
algorithms namely Dijkstra’s algorithm. It is noted that Dijkstra’s algorithm solves the
single source shortest path problem. The function of Dijkstra's algorithm cannot
handle negative edge weights. It is noted that if there is a negative cycle there is no
shortest path.
The following points will give result analysis of the algorithm for some
application specific.
40

 Computational Cost Summary: the maximum time over all process


depends on number of vertex and edges.
 Efficiency in terms of speed: with increasing number of process, Dijkstra’s
algorithm eventually becomes faster because no communication occurs.
 Time complexity: the complexity of the shortest path algorithms depends
on the number of vertices, number of edges, edge length. Another
observation is that the time complexity of the Dijkstra’s algorithm depends
on the number of vertices and is inversely proportional to the number of
vertices.
 Performance and Efficiency: Dijkstra’s algorithm is easy to implement
and thus the debugging of it is also simpler.

4.6. Summary
In this chapter, system design has been explained with the aid of block
diagram. It has been described the implementation steps for shorstest path system
using Dijkstra’s algorithm. Then, locating the verticies on the map and the calculation
of the shortest path system has been mentioned. Finally, this is represented as the
simulation process of the proposed system using Python programming language.

You might also like