Support edge ids in util::pathfinder
This commit is contained in:
parent
740fab84be
commit
e28a78166e
1 changed files with 9 additions and 5 deletions
|
|
@ -69,27 +69,31 @@ namespace psemek::util
|
|||
|
||||
Node step()
|
||||
{
|
||||
Node const node = *queue.begin();
|
||||
Node const node = std::move(*queue.begin());
|
||||
queue.erase(queue.begin());
|
||||
|
||||
auto const node_cost = cost[node];
|
||||
|
||||
node_neighbours(node, [&](Node const & neighbour, Cost const & edge_cost){
|
||||
node_neighbours(node, [&]<typename EdgeId = int>(Node neighbour, Cost const & edge_cost, EdgeId const & edge_id = 0){
|
||||
Cost const new_cost = node_cost + edge_cost;
|
||||
|
||||
edge_callback(node, node_cost, neighbour, edge_cost);
|
||||
|
||||
auto it = cost.find(neighbour);
|
||||
|
||||
if (it == cost.end() || new_cost < it->second)
|
||||
{
|
||||
edge_callback(node, node_cost, neighbour, edge_cost, edge_id, true);
|
||||
|
||||
if (it != cost.end())
|
||||
queue.erase(neighbour);
|
||||
|
||||
cost[neighbour] = new_cost;
|
||||
priority[neighbour] = new_cost + heuristic(neighbour);
|
||||
previous[neighbour] = node;
|
||||
queue.insert(neighbour);
|
||||
queue.insert(std::move(neighbour));
|
||||
}
|
||||
else
|
||||
{
|
||||
edge_callback(node, node_cost, neighbour, edge_cost, edge_id, false);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue