GEDLIB  1.0
star.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_STAR_HPP_
28 #define SRC_METHODS_STAR_HPP_
29 
30 namespace ged {
31 
44 template<class UserNodeLabel, class UserEdgeLabel>
45 class Star : public LSAPEBasedMethod<UserNodeLabel, UserEdgeLabel> {
46 
47 public:
48 
49  virtual ~Star();
50 
52 
53 private:
54 
55  enum SortMethod_ {STD, COUNTING};
56 
57  class SortedNodeLabels_ {
58  public:
59  SortedNodeLabels_(const GEDGraph & g, SortMethod_ sort_method);
60 
61  SortedNodeLabels_();
62 
63  void operator=(const SortedNodeLabels_ & sorted_edge_labels);
64 
65  const std::vector<LabelID> & get_incident_labels(GEDGraph::NodeID) const;
66 
67  private:
68  std::map<GEDGraph::NodeID, std::vector<LabelID>> sorted_node_labels_;
69  };
70 
71  SortMethod_ sort_method_;
72 
73  std::map<GEDGraph::GraphID, SortedNodeLabels_> sorted_node_labels_;
74 
75  // Inherited member functions from LSAPEBasedMethod.
76 
77  virtual void lsape_populate_instance_(const GEDGraph & g, const GEDGraph & h, DMatrix & lsape_instance) final;
78 
79  virtual bool lsape_parse_option_(const std::string & option, const std::string & arg) final;
80 
81  virtual std::string lsape_valid_options_string_() const final;
82 
83  virtual void lsape_set_default_options_() final;
84 
85  virtual void lsape_init_graph_(const GEDGraph & graph) final;
86 
87  virtual double lsape_lower_bound_scaling_factor_(const GEDGraph & g, const GEDGraph & h) final;
88 
89  // Helper member functions.
90 
91  double compute_substitution_cost_(const GEDGraph & g, const GEDGraph & h, GEDGraph::NodeID i, GEDGraph::NodeID k,
92  const SortedNodeLabels_ & sorted_node_labels_g, const SortedNodeLabels_ & sorted_node_labels_h) const;
93 
94  double compute_deletion_cost_(const GEDGraph & g, GEDGraph::NodeID i) const;
95 
96  double compute_insertion_cost_(const GEDGraph & h, GEDGraph::NodeID k) const;
97 };
98 
99 }
100 
101 #endif /* SRC_METHODS_STAR_HPP_ */
virtual bool lsape_parse_option_(const std::string &option, const std::string &arg) final
Parses one option that is not among the ones shared by all derived classes of ged::LSAPEBasedMethod.
Definition: star.ipp:70
Contains the standardized input data along with basic functionality.
Definition: ged_data.hpp:55
virtual void lsape_populate_instance_(const GEDGraph &g, const GEDGraph &h, DMatrix &lsape_instance) final
Populates the LSAPE instance.
Definition: star.ipp:89
Computes lower and upper bounds for uniform edit costs.
Definition: star.hpp:45
virtual std::string lsape_valid_options_string_() const final
Returns string of all valid options that are not among the ones shared by all derived classes of ged:...
Definition: star.ipp:63
Abstract class for methods that use lossy transformations to LSAPE for approximating the graph edit d...
virtual double lsape_lower_bound_scaling_factor_(const GEDGraph &g, const GEDGraph &h) final
Returns scaling factor for lower bound.
Definition: star.ipp:118
The normalized input graphs used by GEDLIB. All labels are integers.
Definition: ged_graph.hpp:104
virtual void lsape_init_graph_(const GEDGraph &graph) final
Initializes global variables for one graph.
Definition: star.ipp:49
Global namespace for GEDLIB.
virtual void lsape_set_default_options_() final
Sets all options that are not among the ones shared by all derived classes of ged::LSAPEBasedMethod t...
Definition: star.ipp:56
std::size_t NodeID
Internally used vertex ID type.
Definition: ged_graph.hpp:108