Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Concepts
SupportFunction.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 <limits>
12#include <grid/GridClasses.hpp>
13
14namespace graph::common {
15
17// ---------------------------------------------------------------------------------------------------------------------
18 public:
19
20 template<typename TNode, typename TEdge>
21 static
22 TNode const &
23 other(const TEdge &e, const TNode &n);
24
25 template<typename TNode, typename TEdge>
26 static
27 TNode &
28 other(TEdge &e, const TNode &n);
29
30// ---------------------------------------------------------------------------------------------------------------------
31
32 template<typename TGraph>
33 static
34 typename TGraph::edge_type::weight_type
35 getMinEdgeValue(const TGraph &graph);
36
37 template<typename TCoordinate, typename TEdge>
38 static
41
42 template<typename TCoordinate, typename TEdge>
43 static
46
47// ---------------------------------------------------------------------------------------------------------------------
48
49};
50
51// ====================================================================================================================
52
53template<typename TNode, typename TEdge>
54TNode const &
55SupportFunction::other(const TEdge &e, const TNode &n) {
56 if (n == e.first) return e.second;
57 return e.first;
58}
59
60template<typename TNode, typename TEdge>
61TNode &
62SupportFunction::other(TEdge &e, const TNode &n) {
63 if (n == e.first) return e.second;
64 return e.first;
65}
66
67// ---------------------------------------------------------------------------------------------------------------------
68
69template<typename TGraph>
70typename TGraph::edge_type::weight_type
72 using weight_type = typename TGraph::edge_type::weight_type;
73 weight_type eps = std::numeric_limits<weight_type>::max();
74
75 for (const auto &edge: graph.getEdges()) {
76 if (edge.weight() < eps) {
77 eps = edge.weight();
78 }
79 }
80
81 return eps;
82}
83
84template<typename TCoordinate, typename TEdge>
87 return graph.getUnit();
88}
89
90template<typename TCoordinate, typename TEdge>
93 return graph.getUnit();
94}
95
96// ---------------------------------------------------------------------------------------------------------------------
97
98} // namespace graph::common
99
Definition: SupportFunction.hpp:16
static TGraph::edge_type::weight_type getMinEdgeValue(const TGraph &graph)
Definition: SupportFunction.hpp:71
static TNode const & other(const TEdge &e, const TNode &n)
Definition: WeightedSquareGrid4.hpp:18
Definition: WeightedSquareGrid8.hpp:18
Definition: CapacityEdge.hpp:18
constexpr const T & max(const T &a)
Root case of maximum computation. The maximum from one value is the value itself.
Definition: algorithm.hpp:278
Definition: ReconstructPath.hpp:14
Definition: ReconstructPath.hpp:14