Logo Search packages:      
Sourcecode: vdr-plugin-sudoku version File versions  Download package

bool Algorithm::visit_new_node (  )  [private]

Backtrack through the decision tree until a node was found that hasn't been visited, return true if an unvisited node was found.

Definition at line 70 of file backtrack.cpp.

References BackTrack::Solution::is_last_at(), BackTrack::Solution::reset_at(), and BackTrack::Solution::set_next_at().

Referenced by find_solution().

{
  // If the current node is the rightmost child we must backtrack
  // one level because there are no more children at this level.
  // So we back up until we find a non-rightmost child, then
  // generate the child to the right. If we back up to the top
  // without finding an unvisted child, then all nodes have been
  // generated.
  while (level >= 0 && solution.is_last_at(level))
  {
    solution.reset_at(level);
    --level;
  }
  if (level < 0)
    return false;
  solution.set_next_at(level);
  return true;
}


Generated by  Doxygen 1.6.0   Back to index