/** * function findReversePath * construct the a reversed path from the goal to the start node * Note: we need to revese the path array if we want the path from the start to the goal * @param Node $start_node the first node in the path * @param Node $goal_node the last node in the path * @param Node $last_node the last node been visited in the A* algorthim , we should remove this paramter cause it is not needed * @return array(Node) the shortest path from the goal to the start */ function findReversePath($start_node, $goal_node, $last_node) { $path = array(); $current_node = null; //var_dump($goal_node); // echo '<pre>', print_r($goal_node), '</pre>'; if ($goal_node->parent_node != null) { $path[] = $goal_node; $current_node = $goal_node->parent_node; } while ($current_node->parent_node != null) { $path[] = $current_node; $current_node = $current_node->parent_node; } if (isSameNode($current_node, $start_node)) { $path[] = $current_node; } // echo '<br /> start of the path <br />'; // echo '<pre>', print_r($path), '</pre>'; // echo '<br /> end of the path <br />'; return $path; }
protected function compareDOMNode($a, $b, $msg = 'Compare DOM Node assertion') { if (!$a instanceof DOMNode || !$b instanceof DOMNode) { $s = false; } else { $s = $a . isSameNode($b) ? true : false; } $output = print_r($a, true) . " <strong><compared to></strong> " . print_r($b, true); $this->addEntry($msg, $s, $output); }