$points = array(array(1, 3, 1), array(1, 2, 4), array(2, 3, 1), array(3, 4, 2)); $ourMap = array(); // Read in the points and push them into the map for ($i = 0, $m = count($points); $i < $m; $i++) { $x = $points[$i][0]; $y = $points[$i][1]; $c = $points[$i][2]; $ourMap[$x][$y] = $c; $ourMap[$y][$x] = $c; } // ensure that the distance from a node to itself is always zero // Purists may want to edit this bit out. for ($i = 0; $i < $matrixWidth; $i++) { for ($k = 0; $k < $matrixWidth; $k++) { if ($i == $k) { $ourMap[$i][$k] = 0; } } } // initialize the algorithm class $dijkstra = new Dijkstra($ourMap, I, $matrixWidth); $dijkstra->findShortestPath(1, 3); //to find only path from field 0 to field 13... //$fromClass = $_POST['fromClass']; //$toClass = $_POST['toClass']; //$dijkstra->findShortestPath($fromClass, $toClass); // Display the results echo '<pre>'; echo "\n\n the shortest route from class 1 to 3 is :\n"; echo $dijkstra->getResults(3); echo '</pre>';