Implementation of the program
In this section, we will implement the program in Bosque to calculate the optimal route following the tasks defined in the previous section.
Storing our problem data in an orderly structure
In order to correctly represent our practical case, we will represent our graph through an adjacency matrix stored in a two-dimensional array, as we can see in the next figure:
In this adjacency matrix, we represent the section's weight between two points on the graph. When there is no connection between two points or the same place, it is assigned zero to denote that they are not possible routes.
Now that we have a data matrix, we can implement it in Bosque using Int
value lists, as we can see in the following code:
var graph: List<List<Int>> = List<List<Int>>@{ List<Int>@{0, 2, 3, 0, 0, 0, 0, 0, 0, 0}, ...