The Comparison of Dijsktra’s Algorithm and Flyod Warshall’s Algorithm to Determine The Shortest Path of Traditional Markets in Bandar Lampung City

-Determining the shortest path between one location to another location is one of the problems that usually has to be faced in daily life. The shortest path will affect the shorter time needed, less money used, and others. In this study, we will discuss the comparison of Dijsktra’s Algorithm and Floyd Warshal’s Algorithm to determine the shortest path of the biggest and the most famous traditional market in Bandar Lampung City, which is Bambu Kuning traditional market, to 26 other traditional markets in Bandar Lampung city. The Phyton programming language is used to implement both algorithms on the data of 27 traditional markets. The results show that both algorithms give the same solution. However, the processing time of Dijsktra’s Algorithm (0.1063 seconds) is faster than Floyd Warshal’s algorithm (0.1691 seconds)


Introduction
A traditional market is a location where traders and buyers meet directly to do business activities for buying and selling transactions.There are 27 traditional markets in the city of Bandar Lampung.Among those 27 traditional markets, several markets are famous for their specialty, such as the traditional market which sells various types of fish (Gudang Lelang Market), the market which sells numerous kinds of vegetables and fruits (Farmer's markets/Pasar Tani), as well as the market which sells many types of goods.
The shortest path from Bambu Kuning traditional market to 26 other traditional markets in the city of Bandar Lampung was found in this study using Floyd Warshall's and Dijkstra's algorithms.The solution and running time of the two algorithms will be compared.
In a weighted graph, the shortest path between any two vertices can be found using Dijkstra's algorithm.The weight value of each edge connecting a pair of vertices in the graph, is equal to the distance between that pair of vertices.A weight must have a positive value (weight ≥0) [1].In 1956 the Dijkstra's Algorithm was discovered by Edger Wybe Dijkstra in 1956 and published in 1959, three years later.

Literature Review A. Graph
A structure that consists of V, a non-empty set of vertices, and set E is a graph G(V,E).V= {  1 ,  2 , … ,   } , and E ={eij| i, j  V }of edges which connect the vertices in E. Associated with every edge there is a weight cij, where the weights are nonnegative.An edge that has the same endpoint is called a loop.Parallel edges are two or more edges that join the same pair of vertices.A graph with no parallel edges or a loop is called a simple graph [2].A vertex in a graph can represent a city, computer, warehouse, location, station, and others; while an edge can represent a road, cable, train track, and others.

B. The Shortest Path
A walk is a finite sequence of alternating vertices and edges, that begin and end with a vertex.Every edge in a walk is next to the vertex immediately before and after it.A path is a walk in which no vertex is passed more than once.A path is called a closed path if the original and terminal vertex are the same.In a graph, it is possible to find more than one path between a pair of vertices, except if the graph is a tree.Some methods were already developed to determine the shortest path, including Dijkstra's Algorithms and Flyod Warshall's Algorithm.

C. Dijkstra's Algorithm
A shortest path between two vertices in a graph can be found using the Dijkstra's Algorithm.This algorithm was developed by Dijkstra in 1959 [3].In this algorithm, the weights are assumed to be nonnegative.In general, Dijkstra's Algorithm can be illustrated as follows [4]: Let N= the set of vertices where the shortest path has been found, s is the initial/original vertex.Initiation: N={ s }, di = the distance from s to i, i  V, where V is the set of all vertices under consideration (need to be determined the shortest path from s}.Note that ds = 0 because the distance of vertex s to itself is zero, dj = csj for every j≠s, csj is the weight of edge eij.
The Dijkstra'Algorithm is divided into two stages: I. Determine i ∉ N from so that di= min dj , for j ∉ N.
Add i to N. If N contains all the nodes, stop II.For each node j  N dj = min (dj , di+cij) Go to I. Note that di+cij is the distance from s to j through node i in N. to 41 other hospitals in Lampung.Cantona et al [5] explore Dijkstra' Algorithm in determining the shortest path to museums in Jakarta, and Kai et al [6], implemented Dijkstra's Algorithm in analyzing the system of emergency response.

D. Floyd Warshall's Algorithm
Another algorithm for determining the shortest path between two vertices is Floyd Warshall's Algorithm.Originally, this algorithm determined the shortest path in a directed graph, however, it was also able for an undirected graph.The Floyd Warshall's Algorithm is given as follows [7]: 1. Create an adjacency matrix using distance/weight from the data of the locations under consideration.2. Use every vertex k in V as an intermediary vertex to update the matrix.For each k  V, update distances/weight by using dij = min (dij , dik+ckj).The shortest path connecting every two vertices is found by observing the vertex one at a time and updating the weights and distances accordingly.3.Two possibilities are conceivable for any pair (i,j) of vertices: a. k is not an intermediary vertex between i and j.
In this case, the shortest path between i and j does not contain vertex k. b. k is not an intermediary vertex between i and j.In this case, dij = min dik+ckj.

E. The data
The data of the distances among 27 locations of traditional markets in Bandar Lampung is used.The data was taken on Tuesday, 4 th of April 2023 using Google Map.Table 1 shows the names and locations of 27 traditional markets in Bandar Lampung.Pasar Koga Jl.Teuku Umar, Sidodadi, Kec.Kedaton Based on the data in Table 2, we constructs the graph of those 27 traditional markets in Bandar Lampung as shown in Figure 1.  2 shows the distance among 27 traditional markets in Bandar Lampung.The notation ∞ indicates that there is no direct distance from those two locations, i.e. there is an intermediary location between those two locations.

Table 2
The data of distance of 27 traditional markets in Bandar Lampung (the distance is in km)

A. Implementation of Dijkstra's Algorithm
Dijkstra's Algorithm is implemented on data on Table 2.Because of the space limitation, we only present the first seven iterations out of 26 iterations.
Vertex Distance (km) Table 3 The first seven iteration of Dijkstra's Algorithm : The shortest path from v1 to vj in j th column.
After running the last iteration, we get the following result: The second row of Table 4 shows the shortest path from  1 (Bambu Kuning traditional market) to other 26 traditional markets in Bandar Lampung.Table 5 shows the result after running the last iteration for Floyd Warshall's Algorithm.The table is formed from the last matrix in the last iteration.The last row on Table 4 (indicated in orange colour), shows the last iteration of Dijkstra's Algorithm.The value in that row shows the shortest distance from Bambu Kuning traditional market (v1) to other 26 locations of traditional markets.For Floyd Warshall's Algorithm, On Table 5, the grey colour indicates the distance of one location to itself (wich is zero), and the row in orange colour shows the shortest distance from the origin (Bambu Kuning) to others.There are more information given by Table 5.The last row and the last column (indicate in light blue colour) show the shortest distance from vertex vi to vertex vj ; i, j =1, 2, 3, ..., 27 .In other word, using Flyod Warshall's Algorithm, we not only determine the shortest distance from Bambu Kuning traditional market to other 26 locations, but also the shortest distance from one location of taditional martkets to the other 26 locations.
Based on Table 4 and table 5, we can see that both algorithms give the the same solution, which are:

Dijkstra' s
Algorithm has been applied in many cases, for examples: Aulia et al[1] used it in determining the shortest distance from The Education Authorities of Lampung Province to 30 out of 229 Public Senior High Schools in 15 subdistricts/municipalities in Lampung Province.Two public Senior High Schools represent every subdistrict/municipality.Putriani et al[3] used Dijkstra' Algorithm to find the shortest distance between Lampung Government Hospital (Abdul Muluk hospital),

Figure 1 .
Figure 1.The graph of the location of 27 traditional markets in Bandar Lampung

Figure 2
Figure2shows screenshot of part of the source code, including some input for Dijkstra's Algorithm, while Figure4shows screenshot of part of the source code for Floyd Warshall's Algorithm.Both source codes are written in Phyton programming language.

Figure 2 .Figure 3 .
Figure 2. Screenshot of part of the source code for Dijkstra's Algorithm

Table 5 .Figure 4 .
Figure 4.The screenshot of part of the source code for Flyod Warshall's Algorithm

Table 1
The data of 27 Traditional Markets in Bandar Lampung