Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
ManhattenDistance.hpp
Go to the documentation of this file.
1
6// Copyright (c) 2017 Czech Technical University in Prague | Faculty of Information Technology. All rights reserved.
7
8#pragma once
9
10#include <cmath>
11#include <alib/pair>
12#include <functional>
13
14namespace graph {
15
16namespace heuristic {
17
19// ---------------------------------------------------------------------------------------------------------------------
20
21 public:
22
23 template<typename TCoordinate>
24 static TCoordinate manhattenDistance(const ext::pair<TCoordinate, TCoordinate> &goal,
26
27// ---------------------------------------------------------------------------------------------------------------------
28
29 template<typename TCoordinate>
30 static
31 std::function<TCoordinate(const ext::pair<TCoordinate, TCoordinate> &,
33
34// ---------------------------------------------------------------------------------------------------------------------
35
36};
37
38// =====================================================================================================================
39
40template<typename TCoordinate>
43 return std::abs(node.first - goal.first) + std::abs(node.second - goal.second);
44}
45
46// ---------------------------------------------------------------------------------------------------------------------
47
48template<typename TCoordinate>
49std::function<TCoordinate(const ext::pair<TCoordinate, TCoordinate> &,
51 return manhattenDistance < TCoordinate >;
52}
53
54// ---------------------------------------------------------------------------------------------------------------------
55
56} // namespace heuristic
57
58} // namespace graph
59
Class extending the pair class from the standard library. Original reason is to allow printing of the...
Definition: pair.hpp:43
Definition: ManhattenDistance.hpp:18
static std::function< TCoordinate(const ext::pair< TCoordinate, TCoordinate > &, const ext::pair< TCoordinate, TCoordinate > &)> manhattenDistanceFunction()
Definition: ManhattenDistance.hpp:50
static TCoordinate manhattenDistance(const ext::pair< TCoordinate, TCoordinate > &goal, const ext::pair< TCoordinate, TCoordinate > &node)
Definition: ManhattenDistance.hpp:41
Definition: ReconstructPath.hpp:14
Definition: Node.cpp:11