Senin, 23 Maret 2020

This is the first journey


Source_node = 0
Destination_node = 1

matrix[0][0] = 0
matrix[0][1] = 1
matrix[0][2] = 1
matrix[0][3] = 1
matrix[1][0] = 1
matrix[1][1] = 0
matrix[1][2] = 0
matrix[1][3] = 1
matrix[2][0] = 1
matrix[2][1] = 0
matrix[2][2] = 1
matrix[2][3] = 1

j = 0

'1. Check or list the neighbor of the source_node
TextWindow.WriteLine("Enter the center node: ")
the_center = TextWindow.Read()

'1. Get the count of center's neighbor
TextWindow.WriteLine("")
cn = Array.GetItemCount(matrix[the_center])
TextWindow.WriteLine(cn)

'2. Get the list of center's neighbor (index that have value 1)
j = 0
for i = 0 To cn - 1
  If matrix[the_center][i] = 1 Then
    neighbor_1[j]=i
    j = j + 1
  EndIf
EndFor

'3. display the neighbor_1 list
For i = 0 To array.GetItemCount(neighbor_1) - 1
  TextWindow.WriteLine("This is neighbor " + i + " element :" + neighbor_1[i])
EndFor
  

Tidak ada komentar:

Posting Komentar