I'm having trouble understanding the traveling sales algorithm. Each link node represents a city with an x and y coordinate in a circular linked list. I've managed to get the each city in the linked list through a file that is passed as an argument, and print it out. What i don't understand is the distance for sales trip:

Code:

/* code tags used to keep table alignment */
City | x coord | y coord
---------------------+---------+---------
city1 4.40 7.70
city2 3.30 8.80

Code:

/* code tags used to keep table alignment */
Starting distance for sales trip = 3.11
City | x coord | y coord
---------------------+---------+---------
city1 4.40 7.70
city2 3.30 8.80
Reduced distance for sales trip = 3.11

the formula for determining the distance between two cities is:

Code:

double x1 = 4.40;
double x2 = 3.30;
double y1 = 7.70;
double y2 = 8.80;
->> printf("%.2f", sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2))* 2);

which gives: 3.11, sounds easy right? but it gets more confusing:

the original text file, before the algorithm is run:

Nowhere 28.8 17.6

Somewhere 5.6 79.12

Whoknows 55.3 49.9

Elsewhere 22.22 11.11

after:

Code:

/* code tags used to keep table alignment */
City | x coord | y coord
---------------------+---------+---------
Elsewhere 22.22 11.11
Nowhere 28.80 17.60
Somewhere 5.60 79.12
Whoknows 55.30 49.90
Starting distance for sales trip = 183.62
City | x coord | y coord
---------------------+---------+---------
Elsewhere 22.22 11.11
Nowhere 28.80 17.60
Whoknows 55.30 49.90
Somewhere 5.60 79.12
Reduced distance for sales trip = 178.69

i just don't get how the 'Starting distance for sales trip' and 'Reduced distance for sales trip' are determined. Can anyone give me any hints?