# How to complete a Brute Force Algorithm in VB

I need to complete a Brute Force Algorithm to find the shortest distance to complete a route with 16 cities (meaning going to all 16 cities which is the shortest route?). I've got the the data showing the distance between each city to each other city. However, I'm not sure how to complete a brute force algorithm. Any suggestions? Anyone know how to complete these in VB....Please help.

• : I need to complete a Brute Force Algorithm to find the shortest
: distance to complete a route with 16 cities (meaning going to all 16
: cities which is the shortest route?). I've got the the data showing
: the distance between each city to each other city. However, I'm not
: sure how to complete a brute force algorithm. Any suggestions?
:
The easiest is to use a recursive algorithm. Here's the a setup in pseudocode:
[code]
GetDistance(FromCity, Distance)
begin
if FromCity = DestinationCity then
begin
Distance is route length of the starting city to the destination city
end else for each Connection of FromCity do
begin
GetDistance(ConnectionCity, ConnectionDistance+Distance)
// ConnectionCity = city connected by this connection from fromCity
// ConnectionDistance = distance from the fromCity to ConnectionCity
end
end
[/code]