HiPOP 2.0.0__tar.gz → 3.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {hipop-2.0.0 → hipop-3.0.1}/.clang-tidy +7 -0
- {hipop-2.0.0 → hipop-3.0.1}/.github/workflows/deploy.yaml +1 -1
- {hipop-2.0.0 → hipop-3.0.1}/PKG-INFO +1 -1
- hipop-3.0.1/VERSION.txt +1 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/examples/ParallelKShortestPath.cpp +11 -16
- hipop-3.0.1/cpp/include/hipop/create.h +62 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/include/hipop/graph.h +152 -36
- hipop-3.0.1/cpp/include/hipop/graph_path.h +452 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/include/hipop/graph_path_cost.h +10 -17
- {hipop-2.0.0 → hipop-3.0.1}/cpp/include/hipop/shortest_path.h +70 -45
- {hipop-2.0.0 → hipop-3.0.1}/cpp/src/graph.cpp +31 -36
- {hipop-2.0.0 → hipop-3.0.1}/cpp/src/graph_path_cost.cpp +5 -6
- {hipop-2.0.0 → hipop-3.0.1}/cpp/src/shortest_path.cpp +286 -310
- {hipop-2.0.0 → hipop-3.0.1}/cpp/tests/CMakeLists.txt +1 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/tests/helpers.h +40 -27
- {hipop-2.0.0 → hipop-3.0.1}/cpp/tests/testAStar.cpp +20 -18
- {hipop-2.0.0 → hipop-3.0.1}/cpp/tests/testDijkstra.cpp +36 -35
- {hipop-2.0.0 → hipop-3.0.1}/cpp/tests/testDijkstraSingleSource.cpp +77 -36
- {hipop-2.0.0 → hipop-3.0.1}/cpp/tests/testGraph.cpp +38 -51
- hipop-3.0.1/cpp/tests/testGraphPath.cpp +577 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/tests/testKShortestPath.cpp +4 -3
- {hipop-2.0.0 → hipop-3.0.1}/cpp/tests/testYenKShortestPath.cpp +4 -3
- {hipop-2.0.0 → hipop-3.0.1}/pyproject.toml +1 -1
- {hipop-2.0.0 → hipop-3.0.1}/python/hipop/cpp/graph.cpp +170 -15
- {hipop-2.0.0 → hipop-3.0.1}/python/hipop/cpp/shortest_path.cpp +16 -3
- {hipop-2.0.0 → hipop-3.0.1}/python/hipop/graph.py +5 -0
- hipop-3.0.1/python/tests/test_GraphPath.py +222 -0
- {hipop-2.0.0 → hipop-3.0.1}/python/tests/test_ShortestPath.py +32 -17
- hipop-2.0.0/VERSION.txt +0 -1
- hipop-2.0.0/cpp/include/hipop/create.h +0 -8
- {hipop-2.0.0 → hipop-3.0.1}/.gitattributes +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/.github/workflows/ci.yaml +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/.gitignore +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/.pre-commit-config.yaml +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/CMakeLists.txt +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/CONTRIBUTING.md +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/DEVELOPMENT.md +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/LICENSE +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/README.md +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/cmake/ClangTidySettings.cmake +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/cmake/IPOSettings.cmake +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/cmake/MainSettings.cmake +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/conda/env.yaml +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/CMakeLists.txt +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/cmake/HipopConfig.cmake.in +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/examples/.clang-tidy +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/examples/CMakeLists.txt +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/include/hipop/string_util.h +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/src/create.cpp +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/tests/.clang-tidy +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/tests/sample_graphs.h +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/tests/testGraphMerge.cpp +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/tests/testManhattan.cpp +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/tests/testStringUtil.cpp +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/cpp/tests/testparallelKShortestPath.cpp +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/pyrefly.toml +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/pytest.toml +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/python/CMakeLists.txt +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/python/examples/UpdateCosts.py +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/python/examples/ksp.py +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/python/examples/merge.py +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/python/examples/render.py +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/python/examples/test.py +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/python/hipop/__init__.py.template +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/python/hipop/cpp/main.cpp +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/python/hipop/py.typed +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/python/hipop/render.py +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/python/hipop/shortest_path.py +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/python/tests/test_Graph.py +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/python/tests/test_VersionConsistency.py +0 -0
- {hipop-2.0.0 → hipop-3.0.1}/ruff.toml +0 -0
|
@@ -7,6 +7,7 @@ Checks: # See https://clang.llvm.org/extra/clang-tidy/checks/list.html
|
|
|
7
7
|
|
|
8
8
|
- cppcoreguidelines-*
|
|
9
9
|
- misc-include-cleaner # The other misc-* are worth enabling, but that would mean significant code refactoring.
|
|
10
|
+
- misc-non-private-member-variables-in-classes
|
|
10
11
|
- modernize-*
|
|
11
12
|
- performance-*
|
|
12
13
|
|
|
@@ -49,3 +50,9 @@ CheckOptions:
|
|
|
49
50
|
# The nanobind STL headers provide the C++ <-> Python type casters through template specializations:
|
|
50
51
|
# no symbol from them is referenced directly, but they must be included where the conversions happen.
|
|
51
52
|
misc-include-cleaner.IgnoreHeaders: 'nanobind/stl/.*'
|
|
53
|
+
|
|
54
|
+
# Classes whose fields are ALL public are accepted as plain data structures (to avoid writing
|
|
55
|
+
# trivial getters). Still, this exception to the general rule should be reserved for simple small classes,
|
|
56
|
+
# with no abstraction, and no non-trivial logic implemented in the class.
|
|
57
|
+
# Complex classes MUST keep their fields private (although this check will miss them if they are all public).
|
|
58
|
+
misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: true
|
|
@@ -37,7 +37,7 @@ jobs:
|
|
|
37
37
|
- ubuntu-latest # Arch: x64
|
|
38
38
|
- ubuntu-24.04-arm # Arch: arm64
|
|
39
39
|
- windows-latest # Arch: x64
|
|
40
|
-
- macos-
|
|
40
|
+
- macos-15 # Arch: arm64
|
|
41
41
|
# Do not use the latest macOS runner to ensure backward compatibility.
|
|
42
42
|
# See comment on MACOSX_DEPLOYMENT_TARGET in pyproject.toml for more details.
|
|
43
43
|
|
hipop-3.0.1/VERSION.txt
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
3.0.1
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
#include <cstdlib>
|
|
5
5
|
#include <iostream>
|
|
6
6
|
#include <limits>
|
|
7
|
+
#include <optional>
|
|
7
8
|
#include <string>
|
|
8
9
|
#include <unordered_map>
|
|
9
10
|
#include <vector>
|
|
@@ -41,15 +42,12 @@ int main()
|
|
|
41
42
|
|
|
42
43
|
//auto paths = hipop::parallelKShortestPath(G, origins, destinations, "time", vecMapLabelCosts, {}, 0.1, 0.95, 10, 10, kPaths, 4);
|
|
43
44
|
auto paths = hipop::parallelDijkstra(G, origins, destinations, vecMapLabelCosts, "time", 1, {});
|
|
45
|
+
const std::optional<hipop::PathCost> &path = paths[0];
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
{
|
|
50
|
-
std::cout << "Cost: " << paths[0].second << std::endl;
|
|
51
|
-
|
|
52
|
-
std::cout << "Path size: " << paths[0].first.size()<< std::endl;
|
|
47
|
+
if (path.has_value()) {
|
|
48
|
+
std::cout << "Cost: " << path->second << std::endl;
|
|
49
|
+
std::cout << "Path size (i.e. number of links): " << path->first.size() << std::endl;
|
|
50
|
+
std::cout << "Path: " << path->first << std::endl;
|
|
53
51
|
}
|
|
54
52
|
|
|
55
53
|
// Update costs
|
|
@@ -58,15 +56,12 @@ int main()
|
|
|
58
56
|
G.UpdateCosts( maplinkcosts );
|
|
59
57
|
|
|
60
58
|
auto paths2 = hipop::parallelDijkstra(G, origins, destinations, vecMapLabelCosts, "time", 1, {});
|
|
59
|
+
const std::optional<hipop::PathCost> &path2 = paths2[0];
|
|
61
60
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
{
|
|
67
|
-
std::cout << "Cost: " << paths2[0].second << std::endl;
|
|
68
|
-
|
|
69
|
-
std::cout << "Path size: " << paths2[0].first.size()<< std::endl;
|
|
61
|
+
if (path2.has_value()) {
|
|
62
|
+
std::cout << "Cost: " << path2->second << std::endl;
|
|
63
|
+
std::cout << "Path size (i.e. number of links): " << path2->first.size() << std::endl;
|
|
64
|
+
std::cout << "Path: " << path2->first << std::endl;
|
|
70
65
|
}
|
|
71
66
|
|
|
72
67
|
return EXIT_SUCCESS;
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
#pragma once
|
|
2
|
+
|
|
3
|
+
#include <hipop/graph.h>
|
|
4
|
+
#include <hipop/graph_path.h>
|
|
5
|
+
#include <hipop/string_util.h>
|
|
6
|
+
|
|
7
|
+
#include <stdexcept>
|
|
8
|
+
#include <string>
|
|
9
|
+
#include <utility>
|
|
10
|
+
#include <vector>
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
namespace hipop {
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
OrientedGraph makeManhattan(int n, double linkLength);
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Generate an empty path (i.e. a path with no link) relating the node corresponding to originNodeId
|
|
21
|
+
* to itself in the given graph.
|
|
22
|
+
*
|
|
23
|
+
* @throws std::invalid_argument if the given node ID does not exist in the graph.
|
|
24
|
+
*/
|
|
25
|
+
inline OrientedGraphPath makeEmptyPath(const OrientedGraph &graph, const std::string &originNodeId) {
|
|
26
|
+
const Node *originNode = graph.findNode(originNodeId);
|
|
27
|
+
if (originNode == nullptr) {
|
|
28
|
+
throw std::invalid_argument(StrCat("[makeEmptyPath] Unknown node ID [", originNodeId, "]."));
|
|
29
|
+
}
|
|
30
|
+
return OrientedGraphPath(originNode);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Generate a path made of the links corresponding to the given link IDs in the given graph.
|
|
36
|
+
*
|
|
37
|
+
* @param linkIds Must not be empty.
|
|
38
|
+
* @throws std::invalid_argument if linkIds is empty, if any link ID does not exist in the graph,
|
|
39
|
+
* or if the sequence of links has inconsistent up/down nodes.
|
|
40
|
+
*/
|
|
41
|
+
inline OrientedGraphPath makePath(const OrientedGraph &graph, const std::vector<std::string> &linkIds) {
|
|
42
|
+
|
|
43
|
+
if (linkIds.empty()) {
|
|
44
|
+
throw std::invalid_argument("[makePath] Link list cannot be empty.");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
std::vector<const Link *> links;
|
|
48
|
+
links.reserve(linkIds.size());
|
|
49
|
+
for (const std::string &linkId : linkIds) {
|
|
50
|
+
const Link *link = graph.findLink(linkId);
|
|
51
|
+
if (link == nullptr) {
|
|
52
|
+
throw std::invalid_argument(StrCat("[makePath] Unknown link ID [", linkId, "]."));
|
|
53
|
+
}
|
|
54
|
+
links.emplace_back(link);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
const Node *origin = links[0]->up();
|
|
58
|
+
return { origin, std::move(links) };
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
} // namespace hipop
|
|
@@ -25,21 +25,25 @@ namespace hipop
|
|
|
25
25
|
|
|
26
26
|
|
|
27
27
|
class Link {
|
|
28
|
+
|
|
29
|
+
std::string id_;
|
|
30
|
+
Node *up_;
|
|
31
|
+
Node *down_;
|
|
32
|
+
double length_;
|
|
33
|
+
mapcosts costs_; // costs_[cost-family][cost-metric] -> cost-value
|
|
34
|
+
std::string label_;
|
|
35
|
+
|
|
36
|
+
friend class OrientedGraph; // Access to private fields is needed to add/remove node/link in the graph.
|
|
37
|
+
|
|
28
38
|
public:
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
mid(std::move(id)),
|
|
38
|
-
mup(up),
|
|
39
|
-
mdown(down),
|
|
40
|
-
mcosts(std::move(costs)),
|
|
41
|
-
mlabel(std::move(label)),
|
|
42
|
-
mlength(length)
|
|
39
|
+
|
|
40
|
+
Link(std::string id, Node *up, Node *down, double length, mapcosts costs, std::string label) :
|
|
41
|
+
id_(std::move(id)),
|
|
42
|
+
up_(up),
|
|
43
|
+
down_(down),
|
|
44
|
+
length_(length),
|
|
45
|
+
costs_(std::move(costs)),
|
|
46
|
+
label_(std::move(label))
|
|
43
47
|
{}
|
|
44
48
|
|
|
45
49
|
// Relationships between Node and Link instances are materialized through raw pointers.
|
|
@@ -50,12 +54,49 @@ namespace hipop
|
|
|
50
54
|
Link &operator=(Link &&other) = delete;
|
|
51
55
|
~Link() = default;
|
|
52
56
|
|
|
57
|
+
/**
|
|
58
|
+
* ID of the current link (uniqueness guaranteed among the links of a given OrientedGraph instance).
|
|
59
|
+
*/
|
|
60
|
+
[[nodiscard]] const std::string &id() const {
|
|
61
|
+
return id_;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Upstream node (the current link is an outgoing link for this node).
|
|
66
|
+
*/
|
|
67
|
+
[[nodiscard]] const Node *up() const {
|
|
68
|
+
return up_;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Downstream node (the current link is an incoming link for this node).
|
|
73
|
+
*/
|
|
74
|
+
[[nodiscard]] const Node *down() const {
|
|
75
|
+
return down_;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Geometric length of the link.
|
|
80
|
+
*/
|
|
81
|
+
[[nodiscard]] double length() const {
|
|
82
|
+
return length_;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Cost values assigned to the link.
|
|
87
|
+
*
|
|
88
|
+
* @return `costs()[cost-family][cost-metric]` -> cost value
|
|
89
|
+
*/
|
|
90
|
+
[[nodiscard]] const mapcosts &costs() const {
|
|
91
|
+
return costs_;
|
|
92
|
+
}
|
|
93
|
+
|
|
53
94
|
/**
|
|
54
95
|
* Whether a cost value is set for the current link, assuming the given cost family and cost metric.
|
|
55
96
|
*/
|
|
56
97
|
[[nodiscard]] bool hasCost(const std::string &costFamily, const std::string &costMetric) const {
|
|
57
|
-
auto it1 =
|
|
58
|
-
if (it1 ==
|
|
98
|
+
auto it1 = costs_.find(costFamily);
|
|
99
|
+
if (it1 == costs_.end()) {
|
|
59
100
|
return false;
|
|
60
101
|
}
|
|
61
102
|
auto it2 = it1->second.find(costMetric);
|
|
@@ -74,8 +115,8 @@ namespace hipop
|
|
|
74
115
|
* is explicitly set. Still, 0 is returned to match the legacy behavior.
|
|
75
116
|
*/
|
|
76
117
|
[[nodiscard]] double cost(const std::string &costFamily, const std::string &costMetric) const {
|
|
77
|
-
auto it1 =
|
|
78
|
-
if (it1 ==
|
|
118
|
+
auto it1 = costs_.find(costFamily);
|
|
119
|
+
if (it1 == costs_.end()) {
|
|
79
120
|
return 0;
|
|
80
121
|
}
|
|
81
122
|
auto it2 = it1->second.find(costMetric);
|
|
@@ -85,26 +126,38 @@ namespace hipop
|
|
|
85
126
|
return it2->second;
|
|
86
127
|
}
|
|
87
128
|
|
|
88
|
-
void
|
|
89
|
-
|
|
129
|
+
void setCosts(mapcosts costs) {
|
|
130
|
+
costs_ = std::move(costs);
|
|
90
131
|
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Link label (may be used to categorize links).
|
|
135
|
+
*/
|
|
136
|
+
[[nodiscard]] const std::string &label() const {
|
|
137
|
+
return label_;
|
|
138
|
+
}
|
|
139
|
+
|
|
91
140
|
};
|
|
92
141
|
|
|
93
142
|
|
|
94
143
|
class Node {
|
|
144
|
+
|
|
145
|
+
std::string id_;
|
|
146
|
+
std::array<double, 2> position_;
|
|
147
|
+
std::unordered_map<std::string, const Link *> adj_;
|
|
148
|
+
std::unordered_map<std::string, const Link *> radj_;
|
|
149
|
+
std::string label_;
|
|
150
|
+
mapsets excludeMovements_;
|
|
151
|
+
|
|
152
|
+
friend class OrientedGraph; // Access to private fields is needed to add/remove node/link in the graph.
|
|
153
|
+
|
|
95
154
|
public:
|
|
96
|
-
|
|
97
|
-
std::
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
Node(std::string id, double x, double y, std::string label, mapsets exclude_movements) :
|
|
104
|
-
mid(std::move(id)),
|
|
105
|
-
mposition{ x, y },
|
|
106
|
-
mlabel(std::move(label)),
|
|
107
|
-
mexclude_movements(std::move(exclude_movements))
|
|
155
|
+
|
|
156
|
+
Node(std::string id, double x, double y, std::string label, mapsets excludeMovements) :
|
|
157
|
+
id_(std::move(id)),
|
|
158
|
+
position_{ x, y },
|
|
159
|
+
label_(std::move(label)),
|
|
160
|
+
excludeMovements_(std::move(excludeMovements))
|
|
108
161
|
{}
|
|
109
162
|
|
|
110
163
|
// Relationships between Node and Link instances are materialized through raw pointers.
|
|
@@ -115,6 +168,69 @@ namespace hipop
|
|
|
115
168
|
Node &operator=(Node &&other) = delete;
|
|
116
169
|
~Node() = default;
|
|
117
170
|
|
|
171
|
+
/**
|
|
172
|
+
* ID of the current node (uniqueness guaranteed among the nodes of a given OrientedGraph instance).
|
|
173
|
+
*/
|
|
174
|
+
[[nodiscard]] const std::string &id() const {
|
|
175
|
+
return id_;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* X/Y coordinates of the current node.
|
|
180
|
+
*/
|
|
181
|
+
[[nodiscard]] const std::array<double, 2> &position() const {
|
|
182
|
+
return position_;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Same as `position()[0]`.
|
|
187
|
+
*/
|
|
188
|
+
[[nodiscard]] double x() const {
|
|
189
|
+
return position_[0];
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/**
|
|
193
|
+
* Same as `position()[1]`.
|
|
194
|
+
*/
|
|
195
|
+
[[nodiscard]] double y() const {
|
|
196
|
+
return position_[1];
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Outgoing links from the current node.
|
|
201
|
+
*
|
|
202
|
+
* @return `adj()[adjacent-node-ID]` -> link from the current node to the adjacent node
|
|
203
|
+
*/
|
|
204
|
+
[[nodiscard]] const std::unordered_map<std::string, const Link *> &adj() const {
|
|
205
|
+
return adj_;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Incoming links to the current node.
|
|
210
|
+
*
|
|
211
|
+
* @return `radj()[adjacent-node-ID]` -> link from the adjacent node to the current node
|
|
212
|
+
*/
|
|
213
|
+
[[nodiscard]] const std::unordered_map<std::string, const Link *> &radj() const {
|
|
214
|
+
return radj_;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Node label (may be used to categorize nodes).
|
|
219
|
+
*/
|
|
220
|
+
[[nodiscard]] const std::string &label() const {
|
|
221
|
+
return label_;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Movement restrictions (i.e. forbidden turns) at the current node.
|
|
226
|
+
*
|
|
227
|
+
* @return `excludeMovements()[predecessor-node-ID]` -> IDs of the downstream nodes (i.e. those in `adj()`)
|
|
228
|
+
* that cannot be reached from the current node when arriving from the given predecessor node
|
|
229
|
+
*/
|
|
230
|
+
[[nodiscard]] const mapsets &excludeMovements() const {
|
|
231
|
+
return excludeMovements_;
|
|
232
|
+
}
|
|
233
|
+
|
|
118
234
|
/**
|
|
119
235
|
* Assuming we follow a path in the graph, and that we come from node `predecessor`,
|
|
120
236
|
* this method computes all the allowed exit links from the current node, and invokes
|
|
@@ -129,10 +245,10 @@ namespace hipop
|
|
|
129
245
|
*/
|
|
130
246
|
template<typename Callback>
|
|
131
247
|
void forEachExit(const std::string &predecessor, Callback &&callback) const {
|
|
132
|
-
for (const auto &l :
|
|
133
|
-
auto it =
|
|
134
|
-
if (it ==
|
|
135
|
-
callback(
|
|
248
|
+
for (const auto &l : adj_) {
|
|
249
|
+
auto it = excludeMovements_.find(predecessor);
|
|
250
|
+
if (it == excludeMovements_.end() || it->second.find(l.second->down()->id()) == it->second.end()) {
|
|
251
|
+
callback(l.second);
|
|
136
252
|
}
|
|
137
253
|
}
|
|
138
254
|
}
|