GEDLIB  1.0
partition.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_PARTITION_HPP_
28 #define SRC_METHODS_PARTITION_HPP_
29 
30 namespace ged {
31 
41 template<class UserNodeLabel, class UserEdgeLabel>
42 class Partition : public GEDMethod<UserNodeLabel, UserEdgeLabel> {
43 
44  template<typename HybridUserNodeLabel, typename HybridUserEdgeLabel>
45  friend class Hybrid;
46 
47 public:
48 
49  virtual ~Partition();
50 
52 
53 private:
54 
55  enum SubstructType_ {NODE, EDGE, NODE_EDGE, NODE_EDGE_NODE, NODE_EDGE_EDGE};
56 
57  struct Substruct_ {
58  Substruct_(SubstructType_ type, LabelID label_1, LabelID label_2 = dummy_label(), LabelID label_3 = dummy_label(), GEDGraph::NodeID node_1 = GEDGraph::dummy_node(),
60 
61  SubstructType_ type;
62 
63  LabelID node_label_1;
64 
65  LabelID node_label_2;
66 
67  LabelID edge_label_1;
68 
69  LabelID edge_label_2;
70 
71  GEDGraph::NodeID node_1;
72 
73  GEDGraph::NodeID node_2;
74 
75  GEDGraph::EdgeID edge_1;
76 
77  GEDGraph::EdgeID edge_2;
78 
79  bool operator<(const Substruct_ & rhs) const;
80  };
81 
82  typedef std::map<Substruct_, bool> SubstructMap_;
83 
84  std::map<GEDGraph::GraphID, SubstructMap_> substruct_maps_;
85 
86  std::vector<Substruct_> unmatched_substructs_;
87 
88  // Member functions inherited from GEDMethod.
89 
90  virtual void ged_init_() final;
91 
92  virtual void ged_run_(const GEDGraph & g, const GEDGraph & h, Result & result) final;
93 
94  // Private helper member functions.
95 
96  void init_graph_(const GEDGraph & graph);
97 
98  void init_graphs_(const GEDGraph & g, const GEDGraph & h);
99 
100  const std::vector<Substruct_> & get_unmatched_substructs_() const;
101 
102  void check_node_subtructs_(const GEDGraph & h, const SubstructMap_ & is_substruct_in_g, std::map<GEDGraph::NodeID, bool> & is_deleted_node);
103 
104  void check_edge_subtructs_(const GEDGraph & h, const SubstructMap_ & is_substruct_in_g, std::map<GEDGraph::EdgeID, bool> & is_deleted_edge);
105 
106  void check_node_edge_subtructs_(const GEDGraph & h, const SubstructMap_ & is_substruct_in_g, std::map<GEDGraph::NodeID, bool> & is_deleted_node, std::map<GEDGraph::EdgeID, bool> & is_deleted_edge);
107 
108  void check_node_edge_node_subtructs_(const GEDGraph & h, const SubstructMap_ & is_substruct_in_g, std::map<GEDGraph::NodeID, bool> & is_deleted_node, std::map<GEDGraph::EdgeID, bool> & is_deleted_edge);
109 
110  void check_node_edge_edge_subtructs_(const GEDGraph & h, const SubstructMap_ & is_substruct_in_g, std::map<GEDGraph::NodeID, bool> & is_deleted_node, std::map<GEDGraph::EdgeID, bool> & is_deleted_edge);
111 
112  bool contains_substruct_(const GEDGraph & g, const Substruct_ & substruct) const;
113 
114  bool contains_node_substruct_(const GEDGraph & g, const Substruct_ & substruct) const;
115 
116  bool contains_edge_substruct_(const GEDGraph & g, const Substruct_ & substruct) const;
117 
118  bool contains_node_edge_substruct_(const GEDGraph & g, const Substruct_ & substruct) const;
119 
120  bool contains_node_edge_node_substruct_(const GEDGraph & g, const Substruct_ & substruct) const;
121 
122  bool contains_node_edge_edge_substruct_(const GEDGraph & g, const Substruct_ & substruct) const;
123 
124 };
125 
126 }
127 
128 #endif /* SRC_METHODS_PARTITION_HPP_ */
Computes a lower bound for uniform edit costs.
Definition: partition.hpp:42
Contains the standardized input data along with basic functionality.
Definition: ged_data.hpp:55
virtual void ged_run_(const GEDGraph &g, const GEDGraph &h, Result &result) final
Runs the method with options specified by set_options().
Definition: partition.ipp:57
virtual void ged_init_() final
Initializes the method.
Definition: partition.ipp:48
static EdgeID dummy_edge()
Returns a dummy edge.
Definition: ged_graph.ipp:68
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.
static NodeID dummy_node()
Returns a dummy node.
Definition: ged_graph.ipp:56
The normalized input graphs used by GEDLIB. All labels are integers.
Definition: ged_graph.hpp:104
detail::GedGraphAL::edge_descriptor EdgeID
Internally used edge ID type.
Definition: ged_graph.hpp:110
constexpr LabelID dummy_label()
Returns a dummy label.
Computes a lower bound for uniform edit costs.
Definition: hybrid.hpp:47
Global namespace for GEDLIB.
std::size_t NodeID
Internally used vertex ID type.
Definition: ged_graph.hpp:108