<STYLE><!--H1{font-family : sans-serif,Arial,Tahoma;color :navy ; background-color :white; } BODY{font-family : sans-serif,Arial,Tahoma;color : black;background-color : white;} HR{color : #0086b2;} TH{font-weight: bold;font-family:sans-serif,Arial,Tahoma; font-size:14pt;background-color : magenta;}
.TABLE{font-weight: bold;font-family:sans-serif,Arial,Tahoma; font-size:12pt; background-color:pink; border-colordark:white; color:navy
}
.FCOL{font-weight: bold;font-family:sans-serif,Arial,Tahoma; font-size:14pt;background-color : magenta;}
--></STYLE>
<?
include "Geo.php";
?>
<BODY>
<H1 align="center"> Example of Territorial Distances </H1>
<?
$cities=new Geo;
$cities->AddNode("1","Roma");
$cities->AddNode("2","Milano");
$cities->AddNode("3","Genova");
$cities->AddNode("4","Torino");
$cities->AddNode("5","Venezia");
$cities->AddNode("6","Napoli");
$dist1=array(
"1" => 0,
"2" => 800,
"3" => 600,
"4" => 700,
"5" => 500,
"6" => 200
);
$dist2=array(
"1" => 800,
"2" => 0,
"3" => 200,
"4" => 100,
"5" => 300,
"6" => 1000
);
$dist3=array(
"1" => 600,
"2" => 200,
"3" => 0,
"4" => 100,
"5" => 100,
"6" => 800
);
$dist4=array(
"1" => 700,
"2" => 100,
"3" => 100,
"4" => 0,
"5" => 200,
"6" => 900
);
$dist5=array(
"1" => 500,
"2" => 300,
"3" => 100,
"4" => 200,
"5" => 0,
"6" => 700
);
$dist6=array(
"1" => 200,
"2" => 1000,
"3" => 800,
"4" => 900,
"5" => 700,
"6" => 0
);
$cities->addDistArray("1", $dist1);
$cities->addDistArray("2", $dist2);
$cities->addDistArray("3", $dist3);
$cities->addDistArray("4", $dist4);
$cities->addDistArray("5", $dist5);
$cities->addDistArray("6", $dist6);
$cities->printDistances();
echo "<CENTER>";
echo "<form name='f1' metod=post>";
echo "<font color='navy'><H3>Choose how many cities to visit</h3></font> <input type='text' size=3 name='vargroup'></input>";
echo "<input type='submit' name='submit' value='submit'></input>";
echo "</form>";
echo "</CENTER>";
if (isset($submit))
{
$itinerari=$cities->allDisp($vargroup);
//$iti_desc=$cities->getCityName($itinerari);
//$itidist=$cities->addDistanceToIter($itinerari);
//echo (count($iti_desc)) ."<BR></BR>";
$itidist=$cities->cityPlusDistance($itinerari);
$minim=$cities->minDistance($itidist);
echo "<CENTER>";
echo "<BR></BR>";
echo "<H3><FONT COLOR='RED'>MINIMUM DISTANCE TOUR </FONT></H3>";
while (list($key, $myarr)=each($minim))
{
$d=reset($myarr);
while (list($arrkey, $arrvalue)=each($myarr))
{
echo $arrvalue . " - ";
}
echo "<BR></BR>";
}
echo "</CENTER>";
}
?>
</BODY>
|