GEDLIB  1.0
ged_method.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_METHODS_GED_METHOD_HPP_
28 #define SRC_METHODS_GED_METHOD_HPP_
29 
30 #include "../env/common_types.hpp"
31 #include "../env/ged_data.hpp"
32 #include "../util/misc.hpp"
33 
34 namespace ged {
35 
39 template<class UserNodeLabel, class UserEdgeLabel>
40 class GEDMethod {
41 
42 public:
43 
48  virtual ~GEDMethod() = 0;
49 
55 
62  void set_options(const std::string & options);
63 
69  void run(GEDGraph::GraphID g_id, GEDGraph::GraphID h_id);
70 
77  void run_as_util(const GEDGraph & g, const GEDGraph & h, Result & result);
78 
82  void init();
83 
88  double get_upper_bound() const;
89 
94  double get_lower_bound() const;
95 
100  Seconds get_runtime() const;
101 
106  Seconds get_init_time() const;
107 
112  const NodeMap & get_node_map() const;
113 
114 protected:
115 
120 
125 
126 private:
127 
128  std::map<std::string, std::string> options_;
129 
130  double lower_bound_;
131 
132  double upper_bound_;
133 
134  NodeMap node_map_;
135 
136  Seconds runtime_;
137 
138  Seconds init_time_;
139 
140  // Private helper member functions.
141 
142  void read_options_from_string_(const std::string & options);
143 
144  void tokenize_(const std::string & options, std::vector<std::string> & words) const;
145 
146  bool is_option_name_(std::string & option_name) const;
147 
148  // Virtual member functions to be overridden by derived classes.
149 
154  virtual void ged_init_();
155 
163  virtual void ged_run_(const GEDGraph & g, const GEDGraph & h, Result & result);
164 
172  virtual bool ged_parse_option_(const std::string & option, const std::string & arg);
173 
179  virtual std::string ged_valid_options_string_() const;
180 
185  virtual void ged_set_default_options_();
186 
187 };
188 
189 }
190 
191 #endif /* SRC_METHODS_GED_METHOD_HPP_ */
Contains the standardized input data along with basic functionality.
Definition: ged_data.hpp:55
GEDMethod(const GEDData< UserNodeLabel, UserEdgeLabel > &ged_data)
Constructor.
Definition: ged_method.ipp:39
A class for node maps.
Definition: node_map.hpp:43
virtual std::string ged_valid_options_string_() const
Returns string of all valid options.
Definition: ged_method.ipp:260
std::vector< GEDGraph >::size_type GraphID
Type of internally used graph IDs.
Definition: ged_graph.hpp:112
const GEDData< UserNodeLabel, UserEdgeLabel > & ged_data_
The data on which the method is run.
Definition: ged_method.hpp:124
void run_as_util(const GEDGraph &g, const GEDGraph &h, Result &result)
Runs the method with options specified by set_options().
Definition: ged_method.ipp:129
A wrapper structure for the result of calls to ged::GEDMethod::run_as_util() and ged::GEDMethod::ged_...
Definition: result.hpp:38
virtual void ged_set_default_options_()
Sets all options to default values.
Definition: ged_method.ipp:267
Abstract class for the (suboptimal) computation of the graph edit distance.
Definition: ged_method.hpp:40
double get_lower_bound() const
Returns a lower bound.
Definition: ged_method.ipp:74
Seconds get_runtime() const
Returns the runtime.
Definition: ged_method.ipp:53
const NodeMap & get_node_map() const
Returns a graph matching.
Definition: ged_method.ipp:67
std::chrono::duration< double > Seconds
Internally used type for measurements in seconds.
void run(GEDGraph::GraphID g_id, GEDGraph::GraphID h_id)
Runs the method with options specified by set_options().
Definition: ged_method.ipp:113
double get_upper_bound() const
Returns an upper bound.
Definition: ged_method.ipp:92
void set_options(const std::string &options)
Sets the options of the method.
Definition: ged_method.ipp:99
bool initialized_
A flag that equals true if init() has been called and false otherwise.
Definition: ged_method.hpp:119
virtual bool ged_parse_option_(const std::string &option, const std::string &arg)
Parses one option.
Definition: ged_method.ipp:253
virtual void ged_run_(const GEDGraph &g, const GEDGraph &h, Result &result)
Runs the method with options specified by set_options().
Definition: ged_method.ipp:248
virtual void ged_init_()
Initializes the method.
Definition: ged_method.ipp:243
The normalized input graphs used by GEDLIB. All labels are integers.
Definition: ged_graph.hpp:104
Global namespace for GEDLIB.
Seconds get_init_time() const
Returns the initialization time.
Definition: ged_method.ipp:60
void init()
Initializes the method with options specified by set_options().
Definition: ged_method.ipp:81
virtual ~GEDMethod()=0
Pure virtual destructor.
Definition: ged_method.ipp:35