Analisis Asimtotik Dan Real Time Menggunakan Algoritma S-Dial Untuk Menentukan Jarak Terpendek Antar Kantor Kepolisian Di Medan
A-1
LAMPIRAN
LISTING PROGRAM
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
System.Diagnostics;
namespace WindowsFormsApplication2
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int N = 15;
int IN = 9999;
int[,] cost;
cost = new int[,] {
{ 9999, 450, 9999, 9999, 9999, 9999, 9999,
9999, 9999, 9999, 9999, 9999, 9999, 9999,
2200
{ 9999, 9999, 1300, 9999, 9999, 9999, 9999,
9999, 9999, 2700, 9999, 9999, 9999, 9999,
9999
{ 9999, 9999, 9999, 260, 650, 9999, 9999,
9999, 9999, 9999, 9999, 9999, 9999, 9999,
9999 },
{ 9999, 9999, 9999, 9999, 9999, 650, 9999,
9999, 9999, 9999, 9999, 9999, 9999, 9999,
9999
{ 9999, 9999, 9999, 650, 9999, 600, 9999,
9999, 9999, 9999, 9999, 9999, 9999, 9999,
},
{ 9999, 9999, 9999, 9999, 9999, 9999, 1800,
9999, 9999, 9999, 9999, 9999, 9999, 9999,
9999
{ 9999, 9999, 9999, 9999, 9999, 9999, 9999,
9999, 9999, 1500, 9999, 9999, 9999, 9999,
9999
{ 9999, 9999, 9999, 9999, 9999, 9999, 2100,
9999, 9999, 9999, 9999, 9999, 1900, 9999,
9999
{ 9999, 9999, 9999, 9999, 9999, 9999, 9999,
400, 9999, 9999, 9999, 9999, 9999, 9999,
9999 },
},
},
},
9999
},
},
},
Universitas Sumatera Utara
A-2
{ 9999, 9999, 1800, 9999, 9999,
9999, 450, 9999, 650, 9999, 9999, 9999,
{ 9999, 9999, 9999, 9999, 9999,
9999, 9999, 9999, 9999, 280, 9999, 9999,
{ 1100, 9999, 9999, 9999, 9999,
9999, 9999, 9999, 9999, 9999, 9999, 9999,
{ 9999, 9999, 9999, 9999, 9999,
9999, 9999, 650, 9999, 250, 9999, 9999,
{ 9999, 9999, 9999, 9999, 9999,
2000, 9999, 9999, 9999, 9999, 9999, 9999,
{ 9999, 9999, 9999, 9999, 9999,
9999, 9999, 9999, 9999, 2300, 9999, 800,
};
string[] kantor;
kantor = new string[]{
"Polresta Medan",
"Polsek Percut Sei Tuan",
"Polsek Medan Timur",
"Polsek Sunggal",
"Polsek Namo Rambe",
"Polsek Patumbak",
"Polsek Medan Kota",
"Polsek Medan Baru",
"Polsek Medan Barat",
"Polsek Medan Area",
"Polsek Helvetia",
"Polsek Delitua",
"Sekolah Polisi Negara",
"Satbrimob Sumut",
"Satlantas Polresta Medan"
};
9999, 9999,
9999
9999, 9999,
9999 },
9999, 9999,
9999
9999, 9999,
9999
9999, 9999,
9999
9999, 9999,
9999 }
},
},
},
},
int i, j;
int source, target;
for (i = 0; i < N; i++ )
{
for (j = 0; j < N; i++ )
{
if (cost[i,j] > max && cost[i,j] != IN)
max = cost[i,j];
}
}
int leghtB = N*(max+1);
int bucked[leghtB,N];
for (i = 0; i < N; i++ )
{
for (j = 0; j < N; i++ )
{
bucked[i][j]=IN;
}
}
string value = comboBox1.Text;
byte[] asciib =
Encoding.ASCII.GetBytes(value);
Universitas Sumatera Utara
A-3
source = asciib[0] - 65;
string value2 = comboBox2.Text;
byte[] asciib2 =
Encoding.ASCII.GetBytes(value2);
target = asciib2[0] - 65;
//class shortest path
int[] dist = new int[N];
int[] prev = new int[N];
int[] number = new int[N];
string[] path_kantor = new string[N];
int[] selected = new int[N];
Array.Clear(selected, 0, selected.Length);
int m, min, start, d;
char[] path = new char[N];
Stopwatch sw = Stopwatch.StartNew();
for (i = 0; i < N; i++)
{
dist[i] = IN;
prev[i] = -1;
}
start = source;
selected[start] = 1;
dist[start] = 0;
while (selected[target] == 0)
{
min = IN;
m = 0;
for (i = 0; i < N; i++)
{
d = dist[start] + cost[start, i];
if(dist[start] dist[i] && selected[i] ==0)
{
min = dist[i];
m = i;
}
}
start = m;
selected[start] = 1;
}
sw.Stop();
textBox2.Text =
sw.Elapsed.TotalMilliseconds.ToString();
Universitas Sumatera Utara
A-4
start = target;
j = 0;
while (start != -1)
{
//start = start+65;
path_kantor[j] = kantor[start];
path[j++] = Convert.ToChar(start + 65);
start = prev[start];
}
Array.Reverse(path);
Array.Reverse(path_kantor);
DataTable dt = new DataTable();
dt.Columns.Add("Titik", typeof(char));
dt.Columns.Add("Kantor", typeof(string));
DataRow dr;
for (i = N - j; i < N; i++)
{
dr = dt.NewRow();
dr["Titik"] = path[i];
dr["Kantor"] = path_kantor[i];
dt.Rows.Add(dr);
}
dataGridView1.DataSource = dt;
textBox1.Text = dist[target].ToString();
}
}
}
Universitas Sumatera Utara
B-1
CURRICULUM VITAE
Identitas Pribadi
Nama Lengkap
: RIKI HARYANDI
Nama akrab
: Riki
Tempat Lahir
: Dolok Masihul
Tanggal Lahir
: 10 Oktober 1993
Tinggi/ Berat badan
: 170 cm/ 60 kg
Jenis Kelamin
: Laki-laki
Status Perkawinan
: Belum Menikah
Agama
: Islam
Alamat
: Jalan Listrik No.58 Kecamatan Dolok Masihul
Nomor HP
: 082166047557
E-mail
: rikihariandi2@gmail.com
Pendidikan Formal
Pendidikan
Sekolah
Tahun
SD
SDN 102057 – Dolok Masihul
1999 – 2005
SMP
MTS Islamiyah – Dolok Masiul
2005 – 2008
SMA
MAN – Dolok Masihul
2008 – 2011
Universitas
D3 Teknik Informatika USU – Sumatera Utara
2011 – 2014
Seminar / Workshop / Kursus
Training / Seminar / Workshop
Tempat
Tahun
Seminar Nasional Literasi Informasi USU, Sumatera Utara
2014
(SENARAI)
Universitas Sumatera Utara
LAMPIRAN
LISTING PROGRAM
using
using
using
using
using
using
using
using
using
using
System;
System.Collections.Generic;
System.ComponentModel;
System.Data;
System.Drawing;
System.Linq;
System.Text;
System.Threading.Tasks;
System.Windows.Forms;
System.Diagnostics;
namespace WindowsFormsApplication2
{
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
int N = 15;
int IN = 9999;
int[,] cost;
cost = new int[,] {
{ 9999, 450, 9999, 9999, 9999, 9999, 9999,
9999, 9999, 9999, 9999, 9999, 9999, 9999,
2200
{ 9999, 9999, 1300, 9999, 9999, 9999, 9999,
9999, 9999, 2700, 9999, 9999, 9999, 9999,
9999
{ 9999, 9999, 9999, 260, 650, 9999, 9999,
9999, 9999, 9999, 9999, 9999, 9999, 9999,
9999 },
{ 9999, 9999, 9999, 9999, 9999, 650, 9999,
9999, 9999, 9999, 9999, 9999, 9999, 9999,
9999
{ 9999, 9999, 9999, 650, 9999, 600, 9999,
9999, 9999, 9999, 9999, 9999, 9999, 9999,
},
{ 9999, 9999, 9999, 9999, 9999, 9999, 1800,
9999, 9999, 9999, 9999, 9999, 9999, 9999,
9999
{ 9999, 9999, 9999, 9999, 9999, 9999, 9999,
9999, 9999, 1500, 9999, 9999, 9999, 9999,
9999
{ 9999, 9999, 9999, 9999, 9999, 9999, 2100,
9999, 9999, 9999, 9999, 9999, 1900, 9999,
9999
{ 9999, 9999, 9999, 9999, 9999, 9999, 9999,
400, 9999, 9999, 9999, 9999, 9999, 9999,
9999 },
},
},
},
9999
},
},
},
Universitas Sumatera Utara
A-2
{ 9999, 9999, 1800, 9999, 9999,
9999, 450, 9999, 650, 9999, 9999, 9999,
{ 9999, 9999, 9999, 9999, 9999,
9999, 9999, 9999, 9999, 280, 9999, 9999,
{ 1100, 9999, 9999, 9999, 9999,
9999, 9999, 9999, 9999, 9999, 9999, 9999,
{ 9999, 9999, 9999, 9999, 9999,
9999, 9999, 650, 9999, 250, 9999, 9999,
{ 9999, 9999, 9999, 9999, 9999,
2000, 9999, 9999, 9999, 9999, 9999, 9999,
{ 9999, 9999, 9999, 9999, 9999,
9999, 9999, 9999, 9999, 2300, 9999, 800,
};
string[] kantor;
kantor = new string[]{
"Polresta Medan",
"Polsek Percut Sei Tuan",
"Polsek Medan Timur",
"Polsek Sunggal",
"Polsek Namo Rambe",
"Polsek Patumbak",
"Polsek Medan Kota",
"Polsek Medan Baru",
"Polsek Medan Barat",
"Polsek Medan Area",
"Polsek Helvetia",
"Polsek Delitua",
"Sekolah Polisi Negara",
"Satbrimob Sumut",
"Satlantas Polresta Medan"
};
9999, 9999,
9999
9999, 9999,
9999 },
9999, 9999,
9999
9999, 9999,
9999
9999, 9999,
9999
9999, 9999,
9999 }
},
},
},
},
int i, j;
int source, target;
for (i = 0; i < N; i++ )
{
for (j = 0; j < N; i++ )
{
if (cost[i,j] > max && cost[i,j] != IN)
max = cost[i,j];
}
}
int leghtB = N*(max+1);
int bucked[leghtB,N];
for (i = 0; i < N; i++ )
{
for (j = 0; j < N; i++ )
{
bucked[i][j]=IN;
}
}
string value = comboBox1.Text;
byte[] asciib =
Encoding.ASCII.GetBytes(value);
Universitas Sumatera Utara
A-3
source = asciib[0] - 65;
string value2 = comboBox2.Text;
byte[] asciib2 =
Encoding.ASCII.GetBytes(value2);
target = asciib2[0] - 65;
//class shortest path
int[] dist = new int[N];
int[] prev = new int[N];
int[] number = new int[N];
string[] path_kantor = new string[N];
int[] selected = new int[N];
Array.Clear(selected, 0, selected.Length);
int m, min, start, d;
char[] path = new char[N];
Stopwatch sw = Stopwatch.StartNew();
for (i = 0; i < N; i++)
{
dist[i] = IN;
prev[i] = -1;
}
start = source;
selected[start] = 1;
dist[start] = 0;
while (selected[target] == 0)
{
min = IN;
m = 0;
for (i = 0; i < N; i++)
{
d = dist[start] + cost[start, i];
if(dist[start] dist[i] && selected[i] ==0)
{
min = dist[i];
m = i;
}
}
start = m;
selected[start] = 1;
}
sw.Stop();
textBox2.Text =
sw.Elapsed.TotalMilliseconds.ToString();
Universitas Sumatera Utara
A-4
start = target;
j = 0;
while (start != -1)
{
//start = start+65;
path_kantor[j] = kantor[start];
path[j++] = Convert.ToChar(start + 65);
start = prev[start];
}
Array.Reverse(path);
Array.Reverse(path_kantor);
DataTable dt = new DataTable();
dt.Columns.Add("Titik", typeof(char));
dt.Columns.Add("Kantor", typeof(string));
DataRow dr;
for (i = N - j; i < N; i++)
{
dr = dt.NewRow();
dr["Titik"] = path[i];
dr["Kantor"] = path_kantor[i];
dt.Rows.Add(dr);
}
dataGridView1.DataSource = dt;
textBox1.Text = dist[target].ToString();
}
}
}
Universitas Sumatera Utara
B-1
CURRICULUM VITAE
Identitas Pribadi
Nama Lengkap
: RIKI HARYANDI
Nama akrab
: Riki
Tempat Lahir
: Dolok Masihul
Tanggal Lahir
: 10 Oktober 1993
Tinggi/ Berat badan
: 170 cm/ 60 kg
Jenis Kelamin
: Laki-laki
Status Perkawinan
: Belum Menikah
Agama
: Islam
Alamat
: Jalan Listrik No.58 Kecamatan Dolok Masihul
Nomor HP
: 082166047557
: rikihariandi2@gmail.com
Pendidikan Formal
Pendidikan
Sekolah
Tahun
SD
SDN 102057 – Dolok Masihul
1999 – 2005
SMP
MTS Islamiyah – Dolok Masiul
2005 – 2008
SMA
MAN – Dolok Masihul
2008 – 2011
Universitas
D3 Teknik Informatika USU – Sumatera Utara
2011 – 2014
Seminar / Workshop / Kursus
Training / Seminar / Workshop
Tempat
Tahun
Seminar Nasional Literasi Informasi USU, Sumatera Utara
2014
(SENARAI)
Universitas Sumatera Utara