GEDLIB  1.0
result.ipp
Go to the documentation of this file.
1 /***************************************************************************
2 * *
3 * Copyright (C) 2018 by David B. Blumenthal *
4 * *
5 * This file is part of GEDLIB. *
6 * *
7 * GEDLIB is free software: you can redistribute it and/or modify it *
8 * under the terms of the GNU Lesser General Public License as published *
9 * by the Free Software Foundation, either version 3 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * GEDLIB is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU Lesser General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License along with GEDLIB. If not, see <http://www.gnu.org/licenses/>. *
19 * *
20 ***************************************************************************/
21 
27 #ifndef SRC_ENV_RESULT_IPP_
28 #define SRC_ENV_RESULT_IPP_
29 
30 namespace ged {
31 
33 Result() :
34 node_maps_(),
35 lower_bound_{0.0} {}
36 
37 void
39 set_lower_bound(double lower_bound) {
40  lower_bound_ = lower_bound;
41 }
42 
43 double
45 lower_bound() const {
46  return lower_bound_;
47 }
48 
49 double
51 upper_bound() const {
52  if (node_maps_.empty()) {
53  return std::numeric_limits<double>::infinity();
54  }
55  return node_maps_.at(0).induced_cost();
56 }
57 
58 std::size_t
60 add_node_map(std::size_t num_nodes_g, std::size_t num_nodes_h) {
61  node_maps_.emplace_back(num_nodes_g, num_nodes_h);
62  return (node_maps_.size() - 1);
63 }
64 
65 std::size_t
68  node_maps_.emplace_back(node_map);
69  return (node_maps_.size() - 1);
70 }
71 
72 NodeMap &
74 node_map(std::size_t index_node_map) {
75  return node_maps_.at(index_node_map);
76 }
77 
78 bool
80 is_non_redundant_node_map(std::size_t index_node_map) {
81  for (std::size_t pos{0}; pos < index_node_map; pos++) {
82  if (node_maps_.at(pos) == node_maps_.at(index_node_map)) {
83  node_maps_.erase(node_maps_.begin() + index_node_map);
84  return false;
85  }
86  }
87  for (std::size_t pos{index_node_map + 1}; pos < node_maps_.size(); pos++) {
88  if (node_maps_.at(pos) == node_maps_.at(index_node_map)) {
89  node_maps_.erase(node_maps_.begin() + index_node_map);
90  return false;
91  }
92  }
93  return true;
94 }
95 
96 std::vector<NodeMap> &
99  return node_maps_;
100 }
101 
102 std::size_t
103 Result ::
104 num_node_maps() const {
105  return node_maps_.size();
106 }
107 
108 void
109 Result ::
111  if (node_maps_.empty()) {
112  return;
113  }
114  std::sort(node_maps_.begin(), node_maps_.end());
115  if (node_maps_.size() > num_node_maps) {
116  node_maps_.erase(node_maps_.begin() + num_node_maps + 1, node_maps_.end());
117  }
118 }
119 
120 }
121 
122 #endif /* SRC_ENV_RESULT_IPP_ */
double upper_bound() const
Returns the upper bound for GED.
Definition: result.ipp:51
A class for node maps.
Definition: node_map.hpp:43
void set_lower_bound(double lower_bound)
Sets the lower bound for GED.
Definition: result.ipp:39
Result()
Default constructor.
Definition: result.ipp:33
double lower_bound() const
Returns the lower bound for GED.
Definition: result.ipp:45
std::size_t num_node_maps() const
Returns the number of node maps.
Definition: result.ipp:104
std::vector< NodeMap > & node_maps()
Provides access to all node maps.
Definition: result.ipp:98
void sort_node_maps_and_set_upper_bound(std::size_t num_node_maps=std::numeric_limits< std::size_t >::max())
Sorts the vector of node maps w.r.t non-decreasing induced cost and possibly discards expensive node ...
Definition: result.ipp:110
bool is_non_redundant_node_map(std::size_t index_node_map)
Checks if a node map is already contained in the vector of all node maps and removes it if this is th...
Definition: result.ipp:80
std::size_t add_node_map(std::size_t num_nodes_g, std::size_t num_nodes_h)
Adds an empty node map to the result.
Definition: result.ipp:60
Global namespace for GEDLIB.
NodeMap & node_map(std::size_t index_node_map)
Provides access to a node map.
Definition: result.ipp:74