8class Neighborhood:
public SearchResult<Neighborhood<G>,typename G::node_type, typename G::adj_container_type::hash_function, typename G::adj_container_type::equality_predicate>{
10 using N =
typename G::node_type;
11 using Hash =
typename G::adj_container_type::hash_function;
12 using Equal =
typename G::adj_container_type::equality_predicate;
14 std::unordered_map<N, size_t,Hash,Equal> nodeDistances;
16 bool stopFlag =
false;
19 void init(
const N & start) {
20 subgraph.addNode(start);
21 nodeDistances[start] = 0;
31 Neighborhood(G && subgraph,
const N & start,
size_t order):
Base(),subgraph(
std::move(subgraph)),order(order){
35 void onOpen(
const N & node)
noexcept {
43 void onEdge(
const N & from,
const N & to)
noexcept {
44 nodeDistances.try_emplace(to,nodeDistances.at(from)+1);
50 if(nodeDistances.at(to) + nodeDistances.at(from) < 2*order) {
51 subgraph.addEdge(from,to);
53 if(nodeDistances.at(from) > order){
58 bool stop() const noexcept{
62 auto get() &&
noexcept {
63 return std::move(subgraph);
66 auto get() &
noexcept {
Definition Neighborhood.hpp:8
bool stop() const noexcept
Definition Neighborhood.hpp:58
void onEdge(const N &from, const N &to) noexcept
Definition Neighborhood.hpp:43
Neighborhood(const N &start, size_t order)
Definition Neighborhood.hpp:27
void onClose(const N &node) noexcept
Definition Neighborhood.hpp:39
N node_type
Definition Neighborhood.hpp:25
auto get() &noexcept
Definition Neighborhood.hpp:66
Neighborhood(G &&subgraph, const N &start, size_t order)
Definition Neighborhood.hpp:31
void onOpen(const N &node) noexcept
Definition Neighborhood.hpp:35
auto get() &&noexcept
Definition Neighborhood.hpp:62
CRTP Abstraction of Search Results.
Definition SearchResult.hpp:16
Definition AdjacencyContainer.hpp:4