GEDLIB  1.0
branch_compact.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_COMPACT_HPP_
28 #define SRC_METHODS_BRANCH_COMPACT_HPP_
29 
30 namespace ged {
31 
44 template<class UserNodeLabel, class UserEdgeLabel>
45 class BranchCompact : public GEDMethod<UserNodeLabel, UserEdgeLabel> {
46 
47 public:
48 
49  virtual ~BranchCompact();
50 
52 
53 private:
54 
55  enum SortMethod_ {STD, COUNTING};
56 
57  class SortedUserEdgeLabels_ {
58  public:
59  SortedUserEdgeLabels_(const GEDGraph & g, SortMethod_ sort_method);
60 
61  const std::vector<LabelID> & get_incident_labels(GEDGraph::NodeID) const;
62 
63  private:
64  std::map<GEDGraph::NodeID, std::vector<LabelID>> sorted_edge_labels_;
65  };
66 
67  struct Branch_ {
68 
69  Branch_(LabelID node_label, const std::vector<LabelID> & sorted_edge_labels);
70 
71  Branch_(const Branch_ & branch);
72 
73  LabelID node_label;
74 
75  std::vector<LabelID> sorted_edge_labels;
76 
77  int compare(const Branch_ & rhs) const;
78 
79  bool operator<(const Branch_ & rhs) const;
80 
81  bool operator>(const Branch_ & rhs) const;
82 
83  bool operator==(const Branch_ & rhs) const;
84  };
85 
86  SortMethod_ sort_method_;
87 
88  std::map<GEDGraph::GraphID, std::list<Branch_>> branches_;
89 
90  // Member functions inherited from GEDMethod.
91 
92  virtual void ged_init_() final;
93 
94  virtual void ged_run_(const GEDGraph & g, const GEDGraph & h, Result & result) final;
95 
96  virtual bool ged_parse_option_(const std::string & option, const std::string & arg) final;
97 
98  virtual std::string ged_valid_options_string_() const final;
99 
100  virtual void ged_set_default_options_() final;
101 
102  // Private helper member functions.
103 
104  void init_graph_(const GEDGraph & graph);
105 };
106 
107 }
108 
109 #endif /* SRC_METHODS_BRANCH_COMPACT_HPP_ */
Contains the standardized input data along with basic functionality.
Definition: ged_data.hpp:55
A wrapper structure for the result of calls to ged::GEDMethod::run_as_util() and ged::GEDMethod::ged_...
Definition: result.hpp:38
Abstract class for the (suboptimal) computation of the graph edit distance.
Definition: ged_method.hpp:40
std::size_t LabelID
Internally used type of node and edge labels.
virtual bool ged_parse_option_(const std::string &option, const std::string &arg) final
Parses one option.
virtual void ged_set_default_options_() final
Sets all options to default values.
virtual void ged_run_(const GEDGraph &g, const GEDGraph &h, Result &result) final
Runs the method with options specified by set_options().
The normalized input graphs used by GEDLIB. All labels are integers.
Definition: ged_graph.hpp:104
Global namespace for GEDLIB.
virtual std::string ged_valid_options_string_() const final
Returns string of all valid options.
virtual void ged_init_() final
Initializes the method.
Computes a lower bound for uniform edit costs.
std::size_t NodeID
Internally used vertex ID type.
Definition: ged_graph.hpp:108