GEDLIB  1.0
bp_beam.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_BP_BEAM_HPP_
28 #define SRC_METHODS_BP_BEAM_HPP_
29 
30 namespace ged {
31 
51 template<class UserNodeLabel, class UserEdgeLabel>
52 class BPBeam : public LSBasedMethod<UserNodeLabel, UserEdgeLabel> {
53 
54 public:
55 
56  virtual ~BPBeam();
57 
59 
60 private:
61 
62  class TreeNode_ {
63 
64  public:
65 
66  TreeNode_(const TreeNode_ & tree_node);
67 
68  TreeNode_(const NodeMap & node_map, const std::vector<NodeMap::Assignment> & assignments);
69 
70  TreeNode_(const TreeNode_ & tree_node, const GEDData<UserNodeLabel, UserEdgeLabel> & ged_data, const GEDGraph & g, const GEDGraph & h, std::size_t pos_swapped_assignment);
71 
72  const NodeMap & node_map() const;
73 
74  std::size_t depth() const;
75 
76  bool operator<(const TreeNode_ & tree_node) const;
77 
78  private:
79 
80  NodeMap node_map_;
81 
82  std::vector<NodeMap::Assignment> assignments_;
83 
84  std::size_t depth_;
85  };
86 
87  std::size_t beam_size_;
88 
89  std::size_t num_orderings_;
90 
91  // Member functions inherited from LSBasedMethod.
92 
93  virtual void ls_run_from_initial_solution_(const GEDGraph & g, const GEDGraph & h, double lower_bound, const NodeMap & initial_node_map, NodeMap & output_node_map) final;
94 
95  virtual void ls_set_default_options_() final;
96 
97  virtual bool ls_parse_option_(const std::string & option, const std::string & arg) final;
98 
99  virtual std::string ls_valid_options_string_() const final;
100 
101  // Private helper member functions.
102 
103  void sort_and_shrink_to_beam_size_(std::vector<TreeNode_> & open) const;
104 
105  void shuffle_assignments_(std::vector<NodeMap::Assignment> & assignments);
106 
107 };
108 
109 }
110 
111 
112 
113 
114 #endif /* SRC_METHODS_BP_BEAM_HPP_ */
Abstract class for methods that use variants of local search for upper bounding the graph edit distan...
Contains the standardized input data along with basic functionality.
Definition: ged_data.hpp:55
Computes an upper bound for general edit costs.
Definition: bp_beam.hpp:52
A class for node maps.
Definition: node_map.hpp:43
virtual void ls_set_default_options_() final
Sets all options that are not among the ones shared by all derived classes of ged::LSBasedMethod to d...
Definition: bp_beam.ipp:97
virtual void ls_run_from_initial_solution_(const GEDGraph &g, const GEDGraph &h, double lower_bound, const NodeMap &initial_node_map, NodeMap &output_node_map) final
Runs the local search from an initial node map.
Definition: bp_beam.ipp:48
virtual std::string ls_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: bp_beam.ipp:138
The normalized input graphs used by GEDLIB. All labels are integers.
Definition: ged_graph.hpp:104
virtual bool ls_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::LSBasedMethod.
Definition: bp_beam.ipp:105
Global namespace for GEDLIB.