Perbandingan Algoritma Greedy dan Hill Climbing Untuk Menentukan Fasilitas Kesehatan Tingkat Pertama (FKTP) Terdekat Bagi Peserta BPJS Kesehatan

64

LISTING PROGRAM

DatabaseHelper.cs

using System;
using System.Collections.Generic;
using System.Data.SQLite;
using System.IO;
using System.Windows.Forms;
namespace Skripsi
{
///
/// Description of DatabaseHelper.
///
public class DatabaseHelper
{
string TABEL_1 = "TABEL_NODE";
string TABEL_2 = "TABEL_KONEKSI";
SQLiteConnection sql;

public DatabaseHelper()
{
bool baruDibuat = false;
if(!File.Exists("db.sqlite")){
baruDibuat = true;
SQLiteConnection.CreateFile("db.sqlite");
}
sql = new SQLiteConnection("Data Source=db.sqlite;Version=3;");
sql.Open();
if(baruDibuat){
String sqlSyntax = "CREATE TABLE " + TABEL_1 + " ("
+ "id INTEGER primary key AUTOINCREMENT,"
+ "nama TEXT,"

Universitas Sumatera Utara

65

+ "alamat TEXT,"
+ "x REAL,"

+ "y REAL,"
+ "wilayah TEXT"
+ ")";
SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql);
if(sqlCommand.ExecuteNonQuery() 0){
return true;
} else {
return false;
}
}
public bool updateNode(int id, Node newNode){
String sqlSyntax = "UPDATE " + TABEL_1 + " SET "
+ " nama='" + newNode.getNama() + "',"
+ " alamat='" + newNode.getAlamat() + "',"
+ " x=" + newNode.getX() + ","
+ " y=" + newNode.getY() + ","
+ " wilayah='" + newNode.getWilayah() + "'"
+ " WHERE id = " + id;
SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql);
if(sqlCommand.ExecuteNonQuery() > 0){

return true;
} else {

Universitas Sumatera Utara

68

return false;
}
}
public bool updateNode(int id, String nama, String alamat, float x, float y, String
wilayah){
String sqlSyntax = "UPDATE " + TABEL_1 + " SET "
+ " nama='" + nama + "',"
+ " alamat='" + alamat + "',"
+ " x=" + x + ","
+ " y=" + y + ","
+ " wilayah='" + wilayah + "'"
+ " WHERE id = " + id;
SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql);

if(sqlCommand.ExecuteNonQuery() > 0){
return true;
} else {
return false;
}
}
public bool updateKoneksi(int id, int idAwal, int idTujuan, float jarak){
String sqlSyntax = "UPDATE " + TABEL_2 + " SET "
+ " idAwal=" + idAwal + ","
+ " idAkhir=" + idTujuan + ","
+ " jarak=" + jarak
+ " WHERE id = " + id;
SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql);
if(sqlCommand.ExecuteNonQuery() > 0){
return true;
} else {
return false;
}
}
public bool tambahNode(Node node){

String sqlSyntax = "INSERT INTO " + TABEL_1 + "(nama, alamat, x, y, wilayah) VALUES
("
+ "'" + node.getNama() + "', "
+ "'" + node.getAlamat() + "', "
+ node.getX() + ", "

Universitas Sumatera Utara

69

+ node.getY() + ", "
+ "'" + node.getWilayah() + "'"
+ ")";
SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql);
if(sqlCommand.ExecuteNonQuery() > 0){
return true;
} else {
return false;
}
}

public bool tambahNode(String nama, String alamat, float x, float y, String wilayah){
String sqlSyntax = "INSERT INTO " + TABEL_1 + "(nama, alamat, x, y, wilayah) VALUES
("
+ "'" + nama + "', "
+ "'" + alamat + "', "
+ x + ", "
+ y + ", "
+ "'" + wilayah + "'"
+ ")";
SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql);
if(sqlCommand.ExecuteNonQuery() > 0){
return true;
} else {
return false;
}
}
public bool tambahKoneksi(int idAwal, int idAkhir, float jarak){
String sqlSyntax = "INSERT INTO " + TABEL_2 + "(idAwal, idAkhir, jarak) VALUES ("
+ idAwal + ", "
+ idAkhir + ", "

+ jarak + ")";
SQLiteCommand sqlCommand = new SQLiteCommand(sqlSyntax, sql);
if(sqlCommand.ExecuteNonQuery() > 0){
return true;
} else {
return false;

Universitas Sumatera Utara

70

}
}
}
}

DataKoneksi.cs

using System;
namespace Skripsi

{
///
/// Description of DataKoneksi.
///
public class DataKoneksi
{
public int id, idAwal, idTujuan;
public String asal, tujuan;
public float jarak;
public DataKoneksi()
{
}
public DataKoneksi(int id, int idAwal, String asal, int idTujuan, String tujuan, float jarak){
this.id = id;
this.idAwal = idAwal;
this.asal = asal;
this.idTujuan = idTujuan;
this.tujuan = tujuan;
this.jarak = jarak;
}

}
}

Greedy.cs
using System;

Universitas Sumatera Utara

71

using System.Collections.Generic;
using System.Diagnostics;
namespace Skripsi
{
///
/// Description of Greedy.
///
public class Greedy
{
List semuaNode;

public List hasil;
public float totalJarak;
public TimeSpan runningTime;
public Greedy()
{
}
public Greedy(List semuaNode){
this.semuaNode = semuaNode;
this.hasil = new List();
this.totalJarak = 0;
}
public bool cariRuteTerpendek(Node asal, String tujuan){
Node nodeAktif = asal;
hasil.Add(asal);
Stopwatch startTime = Stopwatch.StartNew();
while(!nodeAktif.getWilayah().Equals(tujuan) || asal == nodeAktif){
float jarakMinimum = float.PositiveInfinity;
Node nodeTerdekat = null;
foreach(Hubungan hub in nodeAktif.getHubungan()){
if(hub.getJarak() < jarakMinimum && !hasil.Contains(hub.getNode())){

jarakMinimum = hub.getJarak();
nodeTerdekat = hub.getNode();
}

Universitas Sumatera Utara

72

}
totalJarak = jarakMinimum == float.PositiveInfinity ? (totalJarak + 0) : (totalJarak +
jarakMinimum);
nodeAktif = nodeTerdekat;
if(nodeAktif == null){
startTime.Stop();
runningTime = startTime.Elapsed;
return false;
} else {
hasil.Add(nodeAktif);
}
}
startTime.Stop();
runningTime = startTime.Elapsed;
return true;
}
}
}

HillClimbing.cs

using System;
using System.Collections.Generic;
using System.Diagnostics;
namespace Skripsi
{
///
/// Description of Hill Climbing.
///
public class HillClimbing
{
public class UjiSampel {
List ruteId;
public Node nodeAkhir;
public float jarak

Universitas Sumatera Utara

73

public UjiSampel(){
this.ruteId = new List();
jarak = 0;
nodeAkhir = new Node();
}
public UjiSampel(List rute){
this.ruteId = new List(rute);
jarak = 0;
nodeAkhir = new Node();
}
public void tambahRute(int id){
this.ruteId.Add(id);
}
public List getRute(){
return this.ruteId;
}
}
List Q;
public UjiSampel hasil = new UjiSampel();
public TimeSpan runningTime;
Node s, g;
public List rute;
List ruteAktif;
public HillClimbing()
{
Q = new List();
rute = new List();
runningTime = new TimeSpan();
ruteAktif = new List();
}

Universitas Sumatera Utara

74

public bool cariRuteTerpendek(Node asal, Node tujuan){
var watch = System.Diagnostics.Stopwatch.StartNew();
s = asal;
g = tujuan;
UjiSampel current = new UjiSampel();
UjiSampel temp = new UjiSampel();
current.nodeAkhir = asal;
ruteAktif.Add(s.getId());
List yangSudahDikerjakan = new List();

while(true){
if(current.nodeAkhir == tujuan){
hasil = current;
watch.Stop();
runningTime = watch.Elapsed;
return true;
} else {
foreach(Hubungan hubungan in current.nodeAkhir.getHubungan()){
bool sudahDilewati = false;
foreach(Node node in yangSudahDikerjakan){
if(node.getId() == hubungan.getNode().getId()){
sudahDilewati = true;
break;
}
}

if(sudahDilewati) continue;
UjiSampel sampel = new UjiSampel(ruteAktif);
sampel.nodeAkhir = hubungan.getNode();

Universitas Sumatera Utara

75

sampel.jarak = current.jarak + hubungan.getJarak();
sampel.tambahRute(hubungan.getNode().getId());

if(Q.Count == 0){
Q.Add(sampel);
continue;
}
for(int i = 0; i < Q.Count; i++){
if(sampel.jarak.CompareTo(Q[i].jarak) == -1){
Q.Insert(i, sampel);
break;
}
if(i == (Q.Count - 1)){
Q.Add(sampel);
break;
}
}
}
}
yangSudahDikerjakan.Add(current.nodeAkhir);
if(Q.Count == 0) return false;
else {
ruteAktif.Clear();
foreach(int id in Q[0].getRute()){
ruteAktif.Add(id);
}
current = Q[0];
Q.RemoveAt(0);
}
}
}
}

Universitas Sumatera Utara

76

Hubungan.cs

using System;
using System.Collections.Generic;
namespace Skripsi
{
///
/// Description of Hubungan.
///
public class Hubungan
{
Node node;
float jarak;
public Node getNode(){
return node;
}
public void setNode(Node node){
this.node = node;
}
public float getJarak(){
return this.jarak;
}
public void setJarak(float jarak){
this.jarak = jarak;
}
public Hubungan()
{
this.node = new Node();
this.jarak = Node.POSITIVE_INFINITY;
}
public Hubungan(Node node, float jarak){
this.node = node;
this.jarak = jarak;
}
}
}

Universitas Sumatera Utara

77

Map.cs

using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Drawing;
using System.Diagnostics;
using System.Drawing.Drawing2D;
namespace Skripsi
{
///
/// Description of Map.
///
public class Map
{
//MARKER
private static float markerTextSize = 7;
//NODE
private static float nodeWidth = 20;
private static float nodeHeight = 20;
private static int nodeTextSize = 8;
//LINK
private static float linkWidth = 1.5F;
private static int linkTextSize = 6;
private static float distanceTextBorderWidth = 2F;
private Panel mapContainer;
private Brush nodeColor;
private Brush linkTextColor;
private Brush nodeNameColor;
private Brush markerColor;
private Brush markerTextColor;
private Pen shortestPathColor;
private Pen linkColor;
private Pen linkTextBorderColor;
private Brush popUpBackground;
private Brush popUpTextColor;

Universitas Sumatera Utara

78

public Graphics mapGraphics;
public Map(Panel groupBox)
{
this.mapContainer = groupBox;
this.mapGraphics = groupBox.CreateGraphics();
this.nodeColor = new SolidBrush(Color.YellowGreen);
this.linkTextColor = new SolidBrush(Color.Black);
this.linkColor = new Pen(Color.Black, linkWidth);
AdjustableArrowCap bigArrow = new AdjustableArrowCap(3, 3);
this.linkColor.CustomStartCap = bigArrow;
this.linkColor.CustomEndCap = bigArrow;
this.nodeNameColor = new SolidBrush(Color.Black);
this.markerColor = new SolidBrush(Color.Yellow);
this.markerTextColor = new SolidBrush(Color.Black);
this.linkTextBorderColor = new Pen(Color.Black, distanceTextBorderWidth);
this.popUpBackground = new SolidBrush(Color.DarkGray);
this.popUpTextColor = new SolidBrush(Color.Black);
this.shortestPathColor = new Pen(Color.OrangeRed, 6);
this.shortestPathColor.CustomEndCap = new AdjustableArrowCap(3, 3);
}
public void drawPopUp(float x, float y, string msg){
Font popUpFont = new Font(new FontFamily("Segoe UI"), nodeTextSize);
SizeF popUpFontDimension = this.mapGraphics.MeasureString(msg, popUpFont);
this.mapGraphics
.FillRectangle(new SolidBrush(Color.DarkGray),
x,
y + popUpFontDimension.Height,

Universitas Sumatera Utara

79

popUpFontDimension.Width,
popUpFontDimension.Height);
this.mapGraphics
.DrawString(msg,
popUpFont,
popUpTextColor,
x,
y + popUpFontDimension.Height);
}
public void drawPath(List items){
PointF[] points = new PointF[items.Count];
for(int index = 0; index < items.Count; index++){
points[index] = new PointF(items[index].getX(), items[index].getY());
}
this.mapGraphics
.DrawLines(shortestPathColor, points);
}
public void drawPath(List items, Pen color){
PointF[] points = new PointF[items.Count];
for(int index = 0; index < items.Count; index++){
points[index] = new PointF(items[index].getX(), items[index].getY());
}
this.mapGraphics
.DrawLines(color, points);
}
public void drawNode(float x, float y, string id, Brush ndColor){
try {
this.mapGraphics
.FillEllipse(ndColor, new RectangleF(x - (float)(nodeWidth / 2.0),
y - (float)(nodeHeight / 2.0),
nodeWidth,
nodeHeight));
Font nodeFont = new Font(new FontFamily("Segoe UI"), nodeTextSize);
float nodeFontWidth = this.mapGraphics.MeasureString(id, nodeFont).Width;

Universitas Sumatera Utara

80

float nodeFontHeight = this.mapGraphics.MeasureString(id, nodeFont).Height;
this.mapGraphics
.DrawString(id.ToString(),
nodeFont,
nodeNameColor,
x - nodeFontWidth / 2,
y - nodeFontHeight / 2);
} catch (Exception e){
MessageBox.Show("Error : " + e.ToString());
}
}
public void drawLink(float x, float y, float x2, float y2, float distance, bool hasil){
try {
Pen routeColor;
if(hasil){
routeColor = shortestPathColor;
} else {
routeColor = linkColor;
}
this.mapGraphics
.DrawLine(routeColor,
x,
y,
x2,
y2);
} catch (Exception e){
MessageBox.Show("Error : " + e.ToString());
}
}
public void drawDistance(float x, float y, float x2, float y2, float distance){
Font linkFont = new Font(new FontFamily("Segoe UI"), linkTextSize);
SizeF linkFontDimension = new
SizeF(this.mapGraphics.MeasureString(distance.ToString(), linkFont));

Universitas Sumatera Utara

81

float posx = ( x + x2 ) / 2;
float posy = ( y + y2 ) / 2;
float textCircleWidth = linkFontDimension.Width;
float textCircleHeight = linkFontDimension.Height;
this.mapGraphics
.FillEllipse(new SolidBrush(Color.White),
posx - (textCircleWidth / 2),
posy - (textCircleHeight / 2),
textCircleWidth,
textCircleHeight
);
this.mapGraphics
.DrawString(distance.ToString(),
linkFont,
linkTextColor,
new PointF(posx - (linkFontDimension.Width / 2),
posy - (linkFontDimension.Height / 2)
)
);
}
public void drawMarker(string sign, float x, float y){
Font markerFont = new Font(new FontFamily("Segoe UI"), markerTextSize);
SizeF markerFontDimension = this.mapGraphics.MeasureString(sign, markerFont);
this.mapGraphics.FillRectangle(markerColor,
x - markerFontDimension.Width / 2,
y + markerFontDimension.Height / 2,
markerFontDimension.Width,
markerFontDimension.Height);
this.mapGraphics.DrawString(sign,
markerFont,
markerTextColor,
x - markerFontDimension.Width / 2,
y + markerFontDimension.Height / 2);
}

Universitas Sumatera Utara

82

public void updateViewPosition(){
this.mapGraphics.Clear(Color.White);
this.mapGraphics = this.mapContainer.CreateGraphics();
this.mapGraphics.TranslateTransform(this.mapContainer.AutoScrollPosition.X,
this.mapContainer.AutoScrollPosition.Y );
}
}
}
Node.cs

using System;
using System.Collections.Generic;
namespace Skripsi
{
///
/// Node menandakan vertex
/// Masing-masing vertex memiliki id, nama, alamat, posisi x dan y serta koneksi
/// ke node lainnya.
///
///
///
public class Node
{
public static float POSITIVE_INFINITY = float.PositiveInfinity;
int id;
String nama, alamat, wilayah;
float x, y, lat, lng;
List hubungan;
public Node()
{
}
public Node(int id, String nama, String alamat, float x, float y, String wilayah){
this.id = id;

Universitas Sumatera Utara

83

this.nama = nama;
this.alamat = alamat;
this.x = x;
this.y = y;
this.wilayah = wilayah;
this.hubungan = new List();
}
public int getId(){
return this.id;
}
public String getAbjad(){
return this.id.ToString();
}
public String getNama() { return this.nama; }
public String getAlamat() { return this.alamat; }
public List getHubungan() { return this.hubungan; }
public float getX() { return this.x; }
public float getY() { return this.y; }
public String getWilayah() {
return this.wilayah;
}
public float cariJarakKe(int id){
foreach(Hubungan hub in hubungan){
if(hub.getNode().getId() == id){
return hub.getJarak();
}
}
return POSITIVE_INFINITY;
}
public void tambahHubungan(Node node, float jarak){
if(node == null){
return;
}
this.hubungan.Add(
new Hubungan(node, jarak)
);

Universitas Sumatera Utara

84

}
}
}

Pengujian.cs

using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using System.Drawing.Drawing2D;
using System.Windows.Forms;
namespace Skripsi
{
///
/// Description of Pengujian.
///
public partial class Pengujian : Form
{
Map map;
List semuaNode, hasilHillClimbing, tujuanDalamWilayah;
DatabaseHelper dbHelper;
Node asal;
String tujuan;
HillClimbing algoHillClimbing;
Greedy algoGreedy;
bool solusiHillClimbing, solusiGreedy;
bool tampilkanRuteHillClimbing, tampilkanRuteGreedy;
float ukuranGaris = 5f;
float ukuranPattern = 5f;
public Pengujian()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();

Universitas Sumatera Utara

85

map = new Map(panel_graph);
dbHelper = new DatabaseHelper();
semuaNode = dbHelper.ambilSemuaNode();
hasilHillClimbing = new List();
asal = null;
tujuan = null;
tampilkanRuteHillClimbing = cb_hillClimbing.Checked;
tampilkanRuteGreedy = cb_greedy.Checked;
isiComboBox();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
}
Node ambilNodeBerdasarkanId(int id){
foreach(Node node in semuaNode){
if(node.getId() == id) return node;
}
return null;
}
void gambarGraph(){
map.mapGraphics.Clear(panel_graph.BackColor);
foreach(Node node in semuaNode){
foreach(Hubungan hubungan in node.getHubungan()){
map.drawLink(node.getX(), node.getY(), hubungan.getNode().getX(),
hubungan.getNode().getY(), hubungan.getJarak(), false);
}
}

if(solusiHillClimbing && tampilkanRuteHillClimbing){
Pen ruteHillClimbing = new Pen(Color.Blue, ukuranGaris);
ruteHillClimbing.DashPattern = new float[]{ukuranPattern, ukuranPattern};
map.drawPath(hasilHillClimbing, ruteHillClimbing);

Universitas Sumatera Utara

86

}
if(solusiGreedy && tampilkanRuteGreedy){
Pen ruteGreedy = new Pen(Color.Yellow, ukuranGaris);
ruteGreedy.DashPattern = new float[]{ukuranPattern, ukuranPattern};
ruteGreedy.DashOffset = 3 * ukuranGaris * ukuranPattern;
map.drawPath(algoGreedy.hasil, ruteGreedy);
}
foreach(Node node in semuaNode){
Brush nodeColor = new SolidBrush(Color.LightGray);
if(node.getWilayah().Equals("MEDAN BARAT")){
nodeColor = new SolidBrush(Color.LightBlue);
} else
if(node.getWilayah().Equals("MEDAN TIMUR")){
nodeColor = new SolidBrush(Color.LightPink);
} else
if(node.getWilayah().Equals("MEDAN HELVETIA")){
nodeColor = new SolidBrush(Color.LightGreen);
}
map.drawNode(node.getX(), node.getY(), node.getAbjad(), nodeColor);
}
foreach(Node node in semuaNode){
foreach(Hubungan hubungan in node.getHubungan()){
map.drawDistance(node.getX(), node.getY(), hubungan.getNode().getX(),
hubungan.getNode().getY(), hubungan.getJarak());
}
}
}
void isiComboBox(){
combobox_asal_pengujian.DataSource = null;
combobox_asal_pengujian.Items.Clear();
combobox_asal_pengujian.DisplayMember = "Text";
combobox_asal_pengujian.ValueMember = "Value";

Universitas Sumatera Utara

87

List items = new List();
foreach(Node node in semuaNode){
items.Add(
new {
Text = node.getNama() + " [" + node.getAbjad() + "] ",
Value = node.getId()
}
);
}
combobox_asal_pengujian.DataSource = new List(items);
}
void Button1Click(object sender, EventArgs e)
{
semuaNode = dbHelper.ambilSemuaNode();
panel_graph.Invalidate();
isiComboBox();
solusiGreedy = false;
solusiHillClimbing = false;
}
void Panel_graphPaint(object sender, PaintEventArgs e)
{
gambarGraph();
}
void Combobox_asal_pengujianSelectedIndexChanged(object sender, EventArgs e)
{
asal =
ambilNodeBerdasarkanId(Convert.ToInt32(combobox_asal_pengujian.SelectedValue));
panel_graph.Invalidate();
}
void Combobox_tujuan_pengujianSelectedIndexChanged(object sender, EventArgs e)
{
tujuan = combobox_tujuan_pengujian.SelectedItem.ToString();
tujuanDalamWilayah = new List();
foreach(Node node in semuaNode){

Universitas Sumatera Utara

88

if(node.getWilayah().Equals(tujuan))
tujuanDalamWilayah.Add(node);
}
panel_graph.Invalidate();
}
void Btn_cari_ruteClick(object sender, EventArgs e)
{
if(asal != null && tujuan != null){
algoGreedy = new Greedy(semuaNode);
algoHillClimbing = new HillClimbing();
solusiHillClimbing = false;
solusiGreedy = true;
float jarakMinimum = float.PositiveInfinity;
TimeSpan runningTimeHill;
List idRute = new List();
foreach(Node node in tujuanDalamWilayah){
algoHillClimbing = new HillClimbing();
if(node == asal) continue;
if(algoHillClimbing.cariRuteTerpendek(asal, node)){
if(algoHillClimbing.hasil.jarak < jarakMinimum){
runningTimeHill = algoHillClimbing.runningTime;
jarakMinimum = algoHillClimbing.hasil.jarak;
idRute = algoHillClimbing.hasil.getRute();
solusiHillClimbing = true;
}
}
}
hasilHillClimbing = new List();
foreach(int id in idRute){
hasilHillClimbing.Add(ambilNodeBerdasarkanId(id));
}
listbox_rute_hill_climbing.Items.Clear();
foreach(Node node in hasilHillClimbing){

Universitas Sumatera Utara

89

listbox_rute_hill_climbing.Items.Add(node.getNama());
}
Node lastItemHillClimbing = hasilHillClimbing.Count > 0 ?
hasilHillClimbing[hasilHillClimbing.Count - 1] : new Node();
if(lastItemHillClimbing.getWilayah() == tujuan){
lbl_hasil_hill_climbing.Text = "Node " + lastItemHillClimbing.getId() + " - " +
lastItemHillClimbing.getNama().ToUpper() + "\n" +
lastItemHillClimbing.getAlamat().ToUpper();
} else {
lbl_hasil_hill_climbing.Text = "Tidak mencapai tujuan";
}
label_running_time_hill_climbing.Text =
algoHillClimbing.runningTime.TotalMilliseconds + " ms";
total_jarak_hill_climbing.Text = jarakMinimum + " km";

algoGreedy.cariRuteTerpendek(asal, tujuan);
listbox_rute_greedy.Items.Clear();
foreach(Node node in algoGreedy.hasil){
listbox_rute_greedy.Items.Add(node.getNama());
}
Node lastItemGreedy = algoGreedy.hasil.Count > 0 ?
algoGreedy.hasil[algoGreedy.hasil.Count - 1] : new Node();
if(lastItemGreedy.getWilayah() == tujuan){
lbl_hasil_greedy.Text = "Node " + lastItemGreedy.getId() + " - " +
lastItemGreedy.getNama().ToUpper() + "\n" + lastItemGreedy.getAlamat().ToUpper();
} else {
lbl_hasil_greedy.Text = "Tidak mencapai tujuan";
}
label_running_time_greedy.Text = algoGreedy.runningTime.TotalMilliseconds + "
ms";
total_jarak_greedy.Text = algoGreedy.totalJarak + " km";
}
panel_graph.Invalidate();
}

Universitas Sumatera Utara

90

void Panel_graphMouseMove(object sender, MouseEventArgs e)
{
foreach(Node node in semuaNode){
float xStart = node.getX() - (35 / 2.0F),
xEnd = xStart + 35,
yStart = node.getY() - (25 / 2.0F),
yEnd = yStart + 25;
if( e.X >= xStart && e.X = yStart && e.Y