Compare Greedy and Dijkstra Algorithm to Find the Shortest Path of

Perpustakaan Unika
PROJECT
Compare Greedy and Dijkstra Algorithm to Find the
Shortest Path of Tourist Sites at Semarang
Frengky Gunawan
05.02.0022
2009
FAKULTAS ILMU KOMPUTER
UNIVERSITAS KATOLIK SOEGIJAPRANATA
Jl. Pawiyatan Luhur IV/1, Bendan Duwur, SEMARANG 50234
Telp. 024-8441555 (hunting) Web: http://www.unika.ac.id
Email: [email protected]
Perpustakaan Unika
APPROVAL and RATIFICATION PAGE
PROJECT REPORT
Compare Greedy and Dijkstra Algorithm to find the shortest path
of tourist Sites at Semarang
This project report already approved and ratified by Dean of Faculty Computer Science and
Supervisor on 12 December 2009
With the approval,
Examiners,
Examiners,
Robertus Setiawan Aji, ST, MTCompIT
NIP : 058.1.2004.264
Gregorius Hendita Artha Kusuma, S.Si., M.Cs
NIP : 058.1.2008.277
Examiners,
Supervisor,
Rosita Herawati, ST., MIT
NIP : 058.1.2004.263
Hironimus Marlon Leong, S.Kom, M.Kom
NIP : 058.1.2007.273
Dean of Faculty of Computer Science,
Hironimus Marlon Leong, S.Kom, M.Kom
NIP : 058.1.2007.273
ii
Perpustakaan Unika
STATEMENT of ORIGINALITY
I, the undersigned :
Name
ID
: Frengky Gunawan
: 05.02.0022
Here by certify that this project was made by myself and not copy or plagiarizes from other
people, except that in writing expressed to the other article.
Semarang, December 12, 2009
Frengky Gunawan
05.02.0022
iii
I
Perpustakaan Unika
FOREWORD
Finally, I can finished my final project which titled : Compare Greedy and Dijkstra
Algorithm to Find the Shortest Path of Tourist Sites at Semarang. Many thanks for God and
many people whose help for finishing this project. In this opportunity, specifically thanks for :
1. God Almighty that give me health, courage and blessing me everyday to finish this
project.
2. My special dad, mom, my sister, and whole my family for their time, support, love, and
pray.
3.
Hironimus Marlon Leong, S.Kom, M.Kom as my supervisor for helping, guiding and
giving me ideas and advice patiently in finishing this project. Sorry for bothering whole
days, Sir.
4. My best friends in Computer Science society Topan Ariandi, Roy Mayta, Adi Saputra,
Indra Saputra, Koko Adrianto, Fredy Setiawan and many more friends. Thanks, my
friends i’m proud to have you all.
“There is no perfect things in this world”, so I would like to apologizes if I made
mistakes in finishing the project and writing this report.
Semarang, December 12, 2009
Frengky Gunawan
iv
Perpustakaan Unika
ABSTRACT
The purpose of this application is to find shortest path from one tourist site to another
tourist sites at Semarang uses Java programming. To find shortest path, this application
compares possibility distances. The most minimum distance at the moment will be stored and
used to calculate the shortest path.
The search methods can use Greedy algorithm and Dijktra algorithm to find the best
solutions, uses Tree for Data Structure and GUI (Graphical User Interface). Greedy and
Dijkstra algorithm have almost same method for search. Greedy algorithm only choose one
distance with the most minimum distance until found destination. Dijkstra algorithm also choose
one distance with the most minimum distance until found destination but the searching process is
not over yet. Dijkstra algorithm calculating all possibility path from starting location to
destination then choose the best solution by compared which ways had the most minimum
distance.
With that two algorithms, this application can guarantee the solutions would be more
accurate. User just pick one solution that he desired. This application can also insert and update
the original data of information which stored in file text.
v
Perpustakaan Unika
TABLE OF CONTENT
APPROVAL and RATIFICATION PAGE.................................................................................... i
STATEMENT of ORIGINALITY…………………………………………………………….….ii
FOREWORD………………………………………………………………………………….…iii
ABSTRACT ……………………………………………………………………………….….....iv
Table of Content ……………………………………………………….…………………………v
Table of Figure …………………………………………………………………………..….......vi
Table of Table ……………………………………………………..……………………….......vii
CHAPTER 1 INTRODUCTION………………………………………………………………….1
1.1 Background ………………………………………………………………………….........1
1.2 Scope …………………………………………………………………………………..…..1
1.3 Objectives ………………………………………………………………………………….2
CHAPTER 2 LITERATURE STUDY …………………………………………………………...3
2.1 Problems……………………………………………………………………………………3
2.2 Tree as Data Structure ……………………………………………………………….........3
2.3 Algorithm…………………………….…………………………………………………….4
2.3.1. Greedy Algorithm…………………………………………………………………..4
2.3.2 Dijkstra Algorithm…………………………………………………………………..4
2.4 Algorithm for Problem……………………………………………………………………..4
CHAPTER 3 PLANNING …………………………………………………………………….….6
3.1 Research Methodology ………………………………………………………………….…6
3.2 Project Management ……………………………………………………………………….6
CHAPTER 4 ANALYSIS AND DESIGN ………………………………………………............7
4.1 Analysis …………………………………………………………………………….……...7
4.1.1 Functional Requirement ……………………………………………………………...7
4.1.1.1. Search Function………………………………………………………………7
4.1.1.2. Insert Function………………………………………………………………..7
4.1.2 Non Functional Requirement ………………………………………………………...7
4.1.2.1. List of Locations……………………………………………………………...7
4.1.2.2. User Interface………………………………………………………………...7
4.2 Design ……………………………………………………………………………...……...8
4.2.1 Use Case Diagram ……………………………………………………………………8
4.2.2 Relation Class Diagram ………………………………………………………………9
CHAPTER 5 IMPLEMENTATION AND TESTING …………………………………..……...13
5.1 Implementation …………………………………………………………………………..13
5.2 Testing ……………………………………………………………………………..........17
CHAPTER 6 CONCLUSION AND FURTHER RESEARCH …………………………..........20
6.1 Conclusion………………………………………………………………………………..20
6.2 Further Research………………………………………………………………………….21
REFERENCES ………………………………………………………………………………….22
vi
Perpustakaan Unika
TABLE OF FIGURE
Figure 2.1 Tree as Data Structure...…………………………………………………………….3
Figure 2.2 Problem Example……………………………………………………….…………..4
Figure 4.1 Use Case Diagram…………………………………………………………………..8
Figure 5.1 Interface…………………………………………………………………………...,17
Figure 5.2 Menu……………………………………………………………………………….17
Figure 5.3 Insert Location……………………………………………………………………..18
Figure 5.4 Data Added………………………………………………………………………..,18
Figure 5.5 Insert Failed………………………………………………………………………..18
Figure 5.6 Input Location……………………………………………………………………...19
Figure 5.7 Greedy and Dijkstra Button………………………………………………………..19
Figure 5.8 Output Greedy and Dijkstra Solutions……………………………………………..19
vii
Perpustakaan Unika
TABLE OF TABLE
Table 3.1 Project Management……………………………………………………………………6
Table 4.2 Class Diagram…………………………………………………………………………..9
Table 4.3 Class Menu………………………………………………………………………........10
Table 4.4 Class Insert…………………………………………………………………………….11
Table 4.5 Class Node…………………………………………………………………………….11
Table 4.6 Class Greedy….……………………………………………………………………….12
Table 4.7 Class Dijkstra….………………………………………………………………………12
viii