67
LISTING PROGRAM Kode Program Algoritma L-Deque: Public Class Ldeque Public graph As New List(Of List(Of edge_))() Private shortestDistances As New List(Of Double)() Private predecessorVertex As New List(Of Double)() Public totalJarak As Double Public path As List(Of Integer) Private watch As New Classes.Stopwatch() Public elapsedTimeMs As Double = 0 Public Sub New(graph As List(Of List(Of edge_))) Me.graph = graph path = New List(Of Integer)() End Sub
Public Sub LQueue(startIndex As Integer, toIndex As Integer) watch.start() path.Add(toIndex) Dim INF As Double = Double.PositiveInfinity Dim deque As New Deque() For Each pair As List(Of edge_) In graph shortestDistances.Add(INF) predecessorVertex.Add(-1) Next shortestDistances(startIndex) = 0 deque.PushBack(startIndex) While deque.Count <> 0 Dim u As Integer = deque.PopFront(Of Integer) For Each pair As edge_ In graph(u) Dim v As Integer = pair.toIndex If shortestDistances(v) > shortestDistances(u) + pair.cost Then If Not deque.Contains(v) Then If (shortestDistances(v) = Double.PositiveInfinity) Then deque.PushBack(v) Else deque.PushFront(v) End If End If shortestDistances(v) = shortestDistances(u) + pair.cost predecessorVertex(v) = u End If Next End While getPath(startIndex, toIndex) totalJarak = shortestDistances(toIndex) elapsedTimeMs = watch.[stop]() End Sub Public Sub getPath(u As Integer, v As Integer) Universitas Sumatera Utara
68 Dim k As Double k = predecessorVertex(v) If k = -1 OrElse u = v Then Return End If path.Add(CInt(Math.Truncate(k))) getPath(u, CInt(Math.Truncate(k))) End Sub End Class
Kode Program Algoritma Floyd : Public Class Floyd Public P As List(Of List(Of Double)) Public M As List(Of List(Of Double)) Public totalJarak As Double Public startIndex As Integer Public endIndex As Integer Public result As List(Of Integer) Public N As Integer Private watch As New Classes.Stopwatch() Public elapsedTimeMs As Double = 0
Public Sub init(inputTable As List(Of List(Of Double)), N As Double) Me.N = CInt(Math.Truncate(N)) P = New List(Of List(Of Double))() result = New List(Of Integer)() M = inputTable For i As Integer = 0 To N - 1 P.Add(New List(Of Double)()) For j As Integer = 0 To N - 1 P(i).Add(-1) Next Next End Sub
Public Function calculateShortestPath(startIndex As Integer, endIndex As Integer) As List(Of Integer) Me.startIndex = startIndex Me.endIndex = endIndex watch.start() result.Add(startIndex) FloydAlgo(M) getPath(startIndex, endIndex) Universitas Sumatera Utara
69 If totalJarak <> Double.PositiveInfinity Then result.Add(endIndex) End If elapsedTimeMs = watch.[stop]() Return result End Function Public Sub getPath(u As Integer, v As Integer) Dim k As Double k = P(u)(v) If k = -1 Then Return End If getPath(u, CInt(Math.Truncate(k))) result.Add(CInt(Math.Truncate(k))) getPath(CInt(Math.Truncate(k)), v) End Sub Public Function FloydAlgo(M As List(Of List(Of Double))) As List(Of List(Of Double)) For k As Integer = 0 To N - 1 For i As Integer = 0 To N - 1 For j As Integer = 0 To N - 1 If M(i)(k) + M(k)(j) < M(i)(j) Then M(i)(j) = M(i)(k) + M(k)(j) P(i)(j) = k End If Next Next Next totalJarak = M(startIndex)(endIndex) Return M End Function Public Function min(i As Integer, j As Integer) As Integer If i > j Then Return j End If Return i End Function End Class
Universitas Sumatera Utara
70
CURRICULUM VITAE
Data Diri Nama
: Kevin Irfanda
Tempat/Tanggal Lahir
: Medan, 20 November 1994
Alamat Sekarang Medan 20127
: Jl. Binjai km 9,1 No. 17 Kp. Lalang,
Alamat Orang Tua
: Jl. Binjai km 9,1 No. 17 Kp. Lalang, Medan 20127
Agama
: Islam
Jenis Kelamin
: Laki-Laki
Nomor Hp
: 082362675907
Email
:
[email protected]
Riwayat Pendidikan 2000 – 2006
: SD Swasta Supriyadi
2006 – 2009
: SMP Negeri 30 Medan
2009 – 2012
: SMK Negeri 9 Medan
2012 – Sekarang
: S1 Ilmu Komputer Universitas Sumatera Utara, Medan
Keahlian Bahasa
: Indonesia, Inggris
Bahasa Pemrograman : C#, Visual Basic DBMS
: MySQL
Multimedia
: Adobe Flash
Design
: Photoshop
Perkantoran
: Microsoft Office, Microsoft Excel Universitas Sumatera Utara
71 Pengalaman Kepanitiaan 2012
: Anggota Publikasi Dekorasi dan Dokumentasi Dies Natalis IMILKOM
2013
: Anggota Dana Ilkom Goes To School 2013
2014
: Anggota Publikasi Dekorasi dan Dokumentasi Porseni IMILKOM
2014
: Anggota Publikasi Dekorasi dan Dokumentasi PMB 2014
2014
: Anggota Acara Meet & Greet Kam Rabbani
2014
: Anggota Acara ARTechno 2014
2014
: Anggota Acara Science Competition 2014
Pengalaman Organisasi 2014 – 2015
: Anggota Departemen Komunikasi dan Informasi Ikatan Mahasiswa Ilmu Komputer USU (IMILKOM USU)
2015 – 2016
: Sekretaris Departemen Komunikasi dan Informasi Ikatan Mahasiswa Ilmu Komputer USU (IMILKOM USU)
Pengalaman Bekerja 2011
: Praktik Kerja Industri di PT. Telekomunikasi Indonesia, Tbk
2015
: Praktik Kerja Lapangan di PT. Pertamina (Persero)
Seminar 2014
: Seminar Nasional Literasi Informasi “SENARAI”
Universitas Sumatera Utara