GEDLIB  1.0
node_map.hpp
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_NODE_MAP_HPP_
28 #define SRC_ENV_NODE_MAP_HPP_
29 
30 #include "ged_graph.hpp"
31 #include "common_types.hpp"
32 
33 namespace ged {
34 
43 class NodeMap {
44 
45 public:
46 
47  typedef std::pair<GEDGraph::NodeID, GEDGraph::NodeID> Assignment;
48 
54  NodeMap(std::size_t num_nodes_g, std::size_t num_nodes_h);
55 
60  NodeMap(const NodeMap & node_map);
61 
66  void operator=(const NodeMap & node_map);
67 
71  void clear();
72 
77  bool empty() const;
78 
83  std::size_t num_source_nodes() const;
84 
89  std::size_t num_target_nodes() const;
90 
97  bool complete(const GEDGraph & g, const GEDGraph & h) const;
98 
105 
112 
119  void as_relation(std::vector<Assignment> & relation) const;
120 
125  double induced_cost() const;
126 
134 
139  void erase_image(GEDGraph::NodeID node);
140 
146 
151  void set_induced_cost(double induced_cost);
152 
158  bool operator<(const NodeMap & node_map) const;
159 
165  bool operator==(const NodeMap & node_map) const;
166 
167 private:
168 
169  std::vector<GEDGraph::NodeID> forward_map_;
170 
171  std::vector<GEDGraph::NodeID> backward_map_;
172 
173  double induced_cost_;
174 };
175 
183 std::ostream & operator<<(std::ostream & os, const NodeMap & node_map);
184 
192 std::ostream & operator<<(std::ostream & os, const NodeMap::Assignment & assignment);
193 
194 }
195 
196 #include "node_map.ipp"
197 
198 #endif /* SRC_ENV_NODE_MAP_HPP_ */
void erase_image(GEDGraph::NodeID node)
Erases image of a node.
Definition: node_map.ipp:122
void as_relation(std::vector< Assignment > &relation) const
Constructs the representation as relation.
Definition: node_map.ipp:164
A class for node maps.
Definition: node_map.hpp:43
bool empty() const
Checks if the node map is empty.
Definition: node_map.ipp:65
std::size_t num_source_nodes() const
Returns number of source nodes contained in the node map.
Definition: node_map.ipp:81
ged::GEDGraph class declaration.
GEDGraph::NodeID pre_image(GEDGraph::NodeID node) const
Returns pre-image of a node.
Definition: node_map.ipp:137
ged::NodeMap class definition.
double induced_cost() const
Returns the induced cost.
Definition: node_map.ipp:210
std::ostream & operator<<(std::ostream &os, const NodeMap &node_map)
Streams a node map.
Definition: node_map.ipp:226
bool complete(const GEDGraph &g, const GEDGraph &h) const
Checks if the node map is complete.
Definition: node_map.ipp:93
NodeMap(std::size_t num_nodes_g, std::size_t num_nodes_h)
Default constructor.
Definition: node_map.ipp:33
Type declarations used by various classes.
The normalized input graphs used by GEDLIB. All labels are integers.
Definition: ged_graph.hpp:104
void add_assignment(GEDGraph::NodeID i, GEDGraph::NodeID k)
Add node substitution, insertion, or deletion to the node map.
Definition: node_map.ipp:183
void set_induced_cost(double induced_cost)
Sets the induced cost of the node map.
Definition: node_map.ipp:204
std::size_t num_target_nodes() const
Returns number of target nodes contained in the node map.
Definition: node_map.ipp:87
Global namespace for GEDLIB.
void clear()
Clears the node map.
Definition: node_map.ipp:54
void erase_pre_image(GEDGraph::NodeID node)
Erases pre-image of a node.
Definition: node_map.ipp:149
bool operator==(const NodeMap &node_map) const
Checks if two node maps are the same.
Definition: node_map.ipp:222
GEDGraph::NodeID image(GEDGraph::NodeID node) const
Returns image of a node.
Definition: node_map.ipp:110
bool operator<(const NodeMap &node_map) const
Compares this node map to another node map.
Definition: node_map.ipp:216
void operator=(const NodeMap &node_map)
Assignment operator.
Definition: node_map.ipp:46
std::size_t NodeID
Internally used vertex ID type.
Definition: ged_graph.hpp:108