Pseudo Code Mencari Lintasan Terpendek Pseudo Code Input Ukuran Matriks Private Sub Form_Activate

- isi sj dengan 1 - perbarui di, untuk i = 1, 2, 3, …, n dengan: di baru = min{di lama, dj + mji }.

3.6 Pseudo Code dan Flowchart Algoritma Dynamic Programming

3.6.1 Pseudo Code Mencari Lintasan Terpendek

Private Sub cmdFindShortPath_Click do_search = True current = src dist_fc = 0 flxS.TextMatrix1, current = True flxS.Row = 1 flxS.Col = current flxS.CellForeColor = vbRed flxS.CellFontBold = True flxDist.TextMatrix1, current = 0 Do While do_search For i = 1 To MAX - 1 If myVlflxMap.TextMatrixcurrent, i 0 And _ myVlflxDist.TextMatrix1, i myVlflxMap.TextMatrixcurrent, i + dist_fc Then flxDist.TextMatrix1, i = myVlflxMap.TextMatrixcurrent, i + dist_fc flxPath.TextMatrix1, i = current End If Next i min = INF For i = 1 To MAX - 1 If myVlflxDist.TextMatrix1, i min And flxS.TextMatrix1, i = False Then min = myVlflxDist.TextMatrix1, i current = i dist_fc = myVlflxDist.TextMatrix1, i End If Next i flxS.TextMatrix1, current = True flxS.Row = 1 flxS.Col = current flxS.CellForeColor = vbRed flxS.CellFontBold = True If min = INF Then do_search = False End If Loop iRES_SIZE = 0 Universitas Sumatera Utara makeAllLines_Black lblResult.Caption = Lintasan : current = dest Do While current src If flxPath.TextMatrix1, current = 0 Then lblResult.Caption = NO PATH FROM flxMap.TextMatrix0, src TO flxMap.TextMatrix0, dest lblTheDistance.Caption = Exit Sub End If lblResult.Caption = lblResult.Caption flxMap.TextMatrix0, current addTO_RESULT current lblResult.Caption = lblResult.Caption - current = myVlflxPath.TextMatrix1, current Loop lblResult.Caption = lblResult.Caption flxMap.TextMatrix0, src addTO_RESULT src lblTheDistance.Caption = Tujuan: flxDist.TextMatrix1, dest markLINES End Sub

3.6.2 Pseudo Code Input Ukuran Matriks Private Sub Form_Activate

If SELECTED_SHAPE -1 Then UpDownWidth.Value = Form1.shpSELECTED_SHAPE.Width UpDownHeight.Value = Form1.shpSELECTED_SHAPE.Height End If End Sub Private Sub UpDownWidth_Change If SELECTED_SHAPE -1 Then Form1.shpSELECTED_SHAPE.Width = UpDownWidth.Value If Form1.shpSELECTED_SHAPE.Shape = 1 Or Form1.shpSELECTED_SHAPE.Shape = 3 Then Form1.shpSELECTED_SHAPE.Height = Form1.shpSELECTED_SHAPE.Width End If Form1.theLineCollection.updateLines End If End Sub Private Sub UpDownHeight_Change If SELECTED_SHAPE -1 Then Form1.shpSELECTED_SHAPE.Height = UpDownHeight.Value If Form1.shpSELECTED_SHAPE.Shape = 1 Or Form1.shpSELECTED_SHAPE.Shape = 3 Then Universitas Sumatera Utara Form1.shpSELECTED_SHAPE.Width = Form1.shpSELECTED_SHAPE.Height End If Form1.theLineCollection.updateLines End If End Sub

3.6.3 Pseudo Code Perhitungan Data Matriks