PGROUTING  2.6
pgrouting::algorithms::Pgr_astar< G >::distance_heuristic Class Reference
Inheritance diagram for pgrouting::algorithms::Pgr_astar< G >::distance_heuristic:
Collaboration diagram for pgrouting::algorithms::Pgr_astar< G >::distance_heuristic:

## Public Member Functions

distance_heuristic (B_G &g, V goal, int heuristic, double factor)

distance_heuristic (B_G &g, std::vector< V > goals, int heuristic, double factor)

double operator() (V u)

## Private Attributes

double m_factor

B_Gm_g

std::set< Vm_goals

int m_heuristic

## Detailed Description

### template<class G> class pgrouting::algorithms::Pgr_astar< G >::distance_heuristic

Definition at line 178 of file pgr_astar.hpp.

## Constructor & Destructor Documentation

template<class G>
 pgrouting::algorithms::Pgr_astar< G >::distance_heuristic::distance_heuristic ( B_G & g, V goal, int heuristic, double factor )
inline
template<class G>
 pgrouting::algorithms::Pgr_astar< G >::distance_heuristic::distance_heuristic ( B_G & g, std::vector< V > goals, int heuristic, double factor )
inline

## Member Function Documentation

template<class G>
 double pgrouting::algorithms::Pgr_astar< G >::distance_heuristic::operator() ( V u )
inline

Definition at line 196 of file pgr_astar.hpp.

196  {
197  if (m_heuristic == 0) return 0;
198  if (m_goals.empty()) return 0;
199  double best_h((std::numeric_limits<double>::max)());
200  for (auto goal : m_goals) {
201  double current((std::numeric_limits<double>::max)());
202  double dx = m_g[goal].x() - m_g[u].x();
203  double dy = m_g[goal].y() - m_g[u].y();
204  switch (m_heuristic) {
205  case 0:
206  current = 0;
207  case 1:
208  current = std::fabs((std::max)(dx, dy)) * m_factor;
209  case 2:
210  current = std::fabs((std::min)(dx, dy)) * m_factor;
211  case 3:
212  current = (dx * dx + dy * dy) * m_factor * m_factor;
213  case 4:
214  current = std::sqrt(dx * dx + dy * dy) * m_factor;
215  case 5:
216  current = (std::fabs(dx) + std::fabs(dy)) * m_factor;
217  default:
218  current = 0;
219  }
220  if (current < best_h) {
221  best_h = current;
222  }
223  }
224  {
225  auto s_it = m_goals.find(u);
226  if (!(s_it == m_goals.end())) {
227  // found one more goal
228  m_goals.erase(s_it);
229  }
230  }
231  return best_h;
232  }

## Member Data Documentation

template<class G>
 double pgrouting::algorithms::Pgr_astar< G >::distance_heuristic::m_factor
private

Definition at line 237 of file pgr_astar.hpp.

template<class G>
 B_G& pgrouting::algorithms::Pgr_astar< G >::distance_heuristic::m_g
private

Definition at line 235 of file pgr_astar.hpp.

template<class G>
 std::set< V > pgrouting::algorithms::Pgr_astar< G >::distance_heuristic::m_goals
private

Definition at line 236 of file pgr_astar.hpp.

template<class G>
 int pgrouting::algorithms::Pgr_astar< G >::distance_heuristic::m_heuristic
private

Definition at line 238 of file pgr_astar.hpp.

The documentation for this class was generated from the following file:
• /home/vicky/pgrouting/pgrouting/pgrouting/include/astar/pgr_astar.hpp