public function matching_shortest_routes() { return $this->shortest_routes; } // the shortest possible distance to travel public function shortest_distance() { return $this->shortest_distance; } // returns an array of all the possible routes public function routes() { return $this->all_routes; } } $tsp = new TSP(); $db = new PDO('mysql:host=localhost;dbname=binapp', 'root', ''); $db->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_OBJ); $tsp->add('newquay', 50.413608, -5.083364); $tsp->add('london', 51.500152, -0.126236); $tsp->add('birmingham', 52.483003, -1.893561); $tsp->add('manchester', 53.480712, -2.234377); $tsp->compute(); echo 'Shortest Distance: ' . $tsp->shortest_distance(); echo '<br />Shortest Route: '; print_r($tsp->shortest_route()); echo '<br />Num Routes: ' . count($tsp->routes()); echo '<br />Matching shortest Routes: '; print_r($tsp->matching_shortest_routes()); echo '<br />All Routes: '; print_r($tsp->routes());