On a recent trip back from Florida it came to me that there are no decent vacation planner programs for the TS2068 or Spectrum. The type of program that would do Estimated Time of Arrival, fuel consumption, etc. based on the users own automobile data. It could also provide a map of some of the major interstates and cities.
Thinking about such a program reminded me of the old traveling salesman exercise. The exercise goes as follows, a map is drawn up with five to ten cities and the distances between the cities. Each of the cities is connected to other cities by roads. This can be graphed using points and lines to represent the cities and roads. The object of the exercise is to start at one city and find the shortest path for the salesman to visit all the remaining cities traveling between them (see diagram Travel). On a small scale, this can be done by hand. But what if you had one hundred cities or you had to find the best path for fifty groups of cities? Here is where the old Sinclair will come into play.

To find the best path for our salesman to follow we must have an algorithm. The algorithm we will use is a modified version of Kruskal’s algorithm. This means we will use the Shortest Path First method.
In Kruskal’s algorithm we accept a path in its turn if it does not form a cycle (an endless loop between cities) with paths already accepted, otherwise we reject the path. In addition to this we add two other conditions to meet our goal: A path under consideration must also 1) not cause a node (city) to have more than tow paths already accepted to it and 2) the path must not form a cycle, unless the number of paths equals the number of nodes in the problem.
Let us walk through the example above. First, we consider the lowest value path. In our example it would be five, which is F-G, this will be our first path. The next path would be E-F which is also five. Since there are no more paths of five, we now consider the next shortest, six. We have H-I and C-D. D-F is also six, but it

does not meet our requirements because it would give node F three connecting paths. Next we move on to paths of length seven which gives us B-D (F-I fails our test). For the length eight we find only one path and it also fails, so we move on to nine which gives us B-E and G-H. Thus we are left only to connect node (city) A to the route, and only A-C, length 12 passes our test. Thus we now have the shortest path to visit all of the cities, and it looks like this:

Such a method may not be very helpful to some vacation plans, but as you can see it does have its uses. A favorite example is for routing public telephone money collectors etc.
But how do I program this on my TS1000 or TS2068? Here are a couple of hints, first create an array V(n,n) where n is the total number of nodes. Second, number your nodes. Third, enter each of the path lengths into the array. For instance if the length of the path from node 1-2 is 10 then let V(1,2)=10. If there is no path between two nodes then assign the array 0.
Now set up another empty array (zeroed) to contain the number of of paths connected to each node. This array would be of size n. Now tht we have the data structures set up, all we need to do is write our code following the algorithm we stated above.
I will provide the answer (program) in the next issue in both BASIC and Pascal. Until then, give it a shot and see if you can code it.
–Mike