Dijkstra algorithm

14
UNIVERSITI TEKNOLOGI MARA TERENGGANU FACULTY : COMPUTER & MATHEMATICAL SCIENCES ( CS ) COURSE : PARALLEL PROCESSING (CSC580) GROUP : CS2276A Prepared by : ROHAYU BINTI MOHAMED 2012434738 SITI NOR FATIN GHAZMI 2012616566 SITI FATNIN MOHAMAD NA’IZAM 2012475122 Prepared for : DR HAMIDAH JANTAN

description

 

Transcript of Dijkstra algorithm

Page 1: Dijkstra algorithm

UNIVERSITI TEKNOLOGI MARA TERENGGANU

FACULTY : COMPUTER & MATHEMATICAL SCIENCES ( CS )COURSE : PARALLEL PROCESSING (CSC580)GROUP : CS2276A

Prepared by : ROHAYU BINTI MOHAMED 2012434738

SITI NOR FATIN GHAZMI 2012616566

SITI FATNIN MOHAMAD NA’IZAM 2012475122

Prepared for :DR HAMIDAH JANTAN

Page 2: Dijkstra algorithm

Introduction

In January 2014, Uitm student will start the semester break from 20 January until 20

February. We are a group of students are discussing to travel during our semester break. In

order to make sure that we have enough time to travel, a proper strategy must be including in

our preparation other than money. Kelantan is rich Malay tourism centre with many beautiful

places. Our group have decided to visit Kelantan because there are more beautiful places

there to be visited. The journey will start at Kota Bahru to the National Park at Kuala Koh. In

order to travel from one place to another place, we need to know about the distance.

From the town, we have to find the shortest route to save our time and arrived earlier

to make other activities at Kuala Koh National Park. Our group discover for the route from the

beach to the National Park through some others place to be visited. For examples, Kota

Bharu Trade Centre, Bisikan Bayu Beach, Jeram Linang waterfall, Kelantan River, Stong

mountain, Berangkat mountain and Cintawangsa mountain. The difficulty that we have to

face is we want to still be able to generate the path with minimum cost. By choosing the best

method, we will find the shortest route from Kota Bharu to National Park. The use of Dijkstra

parallel graph algorithm help us to find the minimal cost with shortest distance.

Objective

The main objective of the project is to find the shortest distance to travel from Kota Bharu to

Kuala Koh National Park in Kelantan State in order to ensure that we can save out time,

energy and cost.

Page 3: Dijkstra algorithm

Propose solution

Regarding to the problem that we face before, the suitable map was purposed to find

the shortest distance. The project scope is in Malaysia which is Kelantan state. There are

many places to be visited in Kelantan that we have discovered such as Kota Bharu Trade

Centre, Bisikan Bayu Beach, Jeram Linang waterfall, Kelantan River, Stong Mountain,

Berangkat Mountain and Cintawangsa Mountain.

We need to pass through these places to arrive at our destination which is Kuala Koh

National Park. We may visit the place that will consider the shortest distance for us to reach

there. Then for the next other places to be visit, we also considered about the shortest

distance. The places that will give the shortest distance from the place that we were located

will be choosing.

Page 4: Dijkstra algorithm

Algorithm

In order to find the shortest distance from Seri Tujuh beach to Kuala Koh National

Park, we decide to use Dijkstra parallel graph Algorithm. The Dijkstra parallel graph

Algorithm is preferable solution for this problem. Generally, the solution is the most efficient

used in most cases and give better implementation. Dijkstra parallel graph algorithm was

selected due to the important properties which is solving the problem of finding the

shortest path from a place to a destination that producing a shortest path tree. We

also can find the shortest paths from a places to all places proposed in the same time, hence

this problem is sometimes called the single-source shortest paths problem.

The algorithm finds the path with lowest cost or shortest path between a vertex

(node) in the graph and every other vertex. It can also be used for finding costs of shortest

paths from a single vertex to a single destination vertex by stopping the algorithm once the

shortest path to the destination vertex has been determined. For example, if the vertices of

the graph represent cities and edge path costs represent driving distances between pairs of

cities connected by a direct road, Dijkstra's algorithm can be used to find the shortest route

between one city and all other cities. As a result, the shortest path algorithm is widely used in

network routing protocols, most notably IS-IS and OSPF (Open Shortest Path First).

The node at which we are starting be called the initial node and the distance of first

node be the distance from the initial node to first node. Dijkstra's algorithm will assign some

initial distance values and will try to improve them step by step. Suppose you would like to

find the shortest path between two intersections on a city map, a starting point and a

destination. To start the algorithm, mark the distance to every intersection on the map with

infinity. This is done not to imply there is an infinite distance, but to note that intersection has

not yet been visited. Then, a current intersection at each iteration was selected. For the first

iteration, the current intersection will be the starting point and the distance to it will be zero.

For subsequent iterations after the first, the current intersection will be the closest unvisited

intersection to the starting point because this will be easy to find.

From the current intersection, update the distance to every unvisited intersection that

is directly connected to it. This is done by determining the sum of the distance between an

unvisited intersection and the value of the current intersection, and relabeling the unvisited

intersection with this value if it is less than its current value. In effect, the intersection is

relabelled if the path to it through the current intersection is shorter than the previously

known paths. To facilitate shortest path identification, in pencil, mark the road with an arrow

pointing to the relabelled intersection if you label/relabelled it, and erase all others pointing to

it. After you have updated the distances to each neighbouring intersection, mark the current

intersection as visited and select the unvisited intersection with lowest distance from the

Page 5: Dijkstra algorithm

starting point as the current intersection. Nodes marked as visited are labelled with the

shortest path from the starting point to it and will not be revisited or returned to.

Continue this process of updating the neighbouring intersections with the shortest

distances, then marking the current intersection as visited and moving onto the closest

unvisited intersection until you have marked the destination as visited. Once you have

marked the destination as visited you have determined the shortest path to it, from the

starting point, and can trace your way back, following the arrows in reverse.

Of note is the fact that this algorithm makes no attempt to direct "exploration" towards

the destination as one might expect. Rather, the sole consideration in determining the next

"current" intersection is its distance from the starting point. This algorithm, therefore

"expands outward" from the starting point, interactively considering every node that is closer

in terms of shortest path distance until it reaches the destination. When understood in this

way, it is clear how the algorithm necessarily finds the shortest path. However, it may also

reveal one of the algorithm's weaknesses: its relative slowness in some topologies.

Page 6: Dijkstra algorithm

Shortest route

In order to travel from one place to another place, we need to know about the distance. The

route that we have to choose is started at Kota Bharu and last with Kuala Koh National Park.

The distance from each place to another place was obtained from google maps for the actual

distance. To find the minimal cost which is shortest distance, Dijkstra parallel graph

algorithm was used. The places in the maps were denoted with the symbols. The distance to

source node was set to 0, and the distances to all other nodes to infinity. The symbols of

each places as followed:

Places Symbols

Kota Bharu A

Bt Cintawasa B

Stong mountain C

Berangkat mountain D

Kuala Koh National Park E

The distance was calculated using Dijkstra parallel graph algorithm formula which is refers

to the distance travel from one place to another place to reach goal. The shortest distance

that gives the smallest value was selected as the best solution. Below is the spanning tree

for the maps from Kota Bharu to Kuala Koh National Park.

Page 7: Dijkstra algorithm
Page 8: Dijkstra algorithm
Page 9: Dijkstra algorithm

Shortest path was defined from Kota Bharu to Kuala Koh National park. We need to start our

travelling schedule from Kota Bharu to Stong Mountain. Next, we need to take a root to

Cintawasa Mountain and then continue to the Berangkat Mountain. Lastly, we will arrive at

Kuala Koh National Park from Berangkat Mountain.

The shortest path is : A C B D E

Conclusion

The Dijkstra parallel graph algorithm can achieve better running time by using greedy

algorithm. It can also guarantee to find the shortest path. It computes length of the shortest

path from the Kota Bharu to each of the remaining vertices in the graph to arrive at the

destination. Dijkstra parallel graph algorithm can be used in order to save energy, cost and

time.

Reference

http://en.wikipedia.org/wiki/Dijkstra's_algorithm

http://www.world-islam.com