GEDLIB  1.0
branch_fast.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_BRANCH_FAST_HPP_
28 #define SRC_METHODS_BRANCH_FAST_HPP_
29 
30 namespace ged {
31 
44 template<class UserNodeLabel, class UserEdgeLabel>
45 class BranchFast : public LSAPEBasedMethod<UserNodeLabel, UserEdgeLabel> {
46 
47 public:
48  virtual ~BranchFast();
49 
51 
52 private:
53 
54  enum SortMethod_ {STD, COUNTING};
55 
56  class SortedEdgeLabels_ {
57  public:
58  SortedEdgeLabels_(const GEDGraph & g, SortMethod_ sort_method);
59 
60  SortedEdgeLabels_();
61 
62  void operator=(const SortedEdgeLabels_ & sorted_edge_labels);
63 
64  const std::vector<LabelID> & get_incident_labels(GEDGraph::NodeID) const;
65  private:
66  std::map<GEDGraph::NodeID, std::vector<LabelID>> sorted_edge_labels_;
67  };
68 
69  SortMethod_ sort_method_;
70 
71  std::map<GEDGraph::GraphID, SortedEdgeLabels_> sorted_edge_labels_;
72 
73  // Member functions inherited from LSAPEBasedMethod.
74 
75  virtual bool lsape_parse_option_(const std::string & option, const std::string & arg) final;
76 
77  virtual std::string lsape_valid_options_string_() const final;
78 
79  virtual void lsape_set_default_options_() final;
80 
81  virtual void lsape_populate_instance_(const GEDGraph & g, const GEDGraph & h, DMatrix & master_problem) final;
82 
83  virtual void lsape_init_graph_(const GEDGraph & graph) final;
84 
85  // Private helper member functions.
86 
87  double compute_substitution_cost_(const GEDGraph & g, const GEDGraph & h, GEDGraph::NodeID i, GEDGraph::NodeID k,
88  const SortedEdgeLabels_ & sorted_edge_labels_g, const SortedEdgeLabels_ & sorted_edge_labels_h) const;
89 
90  double compute_deletion_cost_(const GEDGraph & g, GEDGraph::NodeID i) const;
91 
92  double compute_insertion_cost_(const GEDGraph & h, GEDGraph::NodeID k) const;
93 };
94 
95 }
96 
97 #endif /* SRC_METHODS_BRANCH_FAST_HPP_ */
virtual void lsape_populate_instance_(const GEDGraph &g, const GEDGraph &h, DMatrix &master_problem) final
Populates the LSAPE instance.
Definition: branch_fast.ipp:88
Contains the standardized input data along with basic functionality.
Definition: ged_data.hpp:55
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: branch_fast.ipp:55
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: branch_fast.ipp:62
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: branch_fast.ipp:69
Computes lower and upper bounds for general edit costs.
Definition: branch_fast.hpp:45
Abstract class for methods that use lossy transformations to LSAPE for approximating the graph edit d...
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: branch_fast.ipp:48
Global namespace for GEDLIB.
std::size_t NodeID
Internally used vertex ID type.
Definition: ged_graph.hpp:108