Open divinity76 opened 9 years ago
function to calculate the total distance
function calculate_total_xy_distance($input_list){
$ret=0;
$startX=$input_list[0]['x'];
$startY=$input_list[0]['y'];
$i=1;
for($i=1;$i<count($input_list,COUNT_NORMAL);++$i){
$ret+=abs($input_list[$i]['x']-$startX)+abs($input_list[$i]['y']-$startY);
$startX=$input_list[$i]['x'];
$startY=$input_list[$i]['y'];
}(
return $ret;
}:
also, if i un-comment
//$tmpdistance=hypot($input_list[$ii]['x'] - $a['x'] ,$input_list[$ii]['y'] - $a['y'] );
the total length goes from 5461 (with the abs approach) to 5336 (with the hypot approach), and looks like this, hmm..
huh, on another map, the hypot approach generated a longer path... oh well, again the difference wasn't much though.
1: it does not start sorting from internic, so the first route after internic is (very) likely to be unoptimal.
2: when it goes from China to Papa New Guina (or whatever the little island is supposed to be), the path looks unoptimal here, so i guess the algorithm is not perfect.. in here: http://imagizer.imageshack.us/a/img538/1734/rauT6r.png