GEDLIB  1.0
subgraph.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_SUBGRAPH_HPP_
28 #define SRC_METHODS_SUBGRAPH_HPP_
29 
30 namespace ged {
31 
48 template<class UserNodeLabel, class UserEdgeLabel>
49 class Subgraph : public LSAPEBasedMethod<UserNodeLabel, UserEdgeLabel> {
50 
51 public:
52 
53  virtual ~Subgraph();
54 
56 
57 private:
58 
59  std::size_t depth_;
60 
61  std::size_t min_depth_;
62 
63  std::size_t max_depth_;
64 
65  std::string infile_;
66 
67  std::string outfile_;
68 
69  std::string exact_options_;
70 
71  std::map<GEDGraph::GraphID, GEDGraph> subgraphs_;
72 
73  Options::GEDMethod exact_method_;
74 
75  // Inherited member functions from LSAPEBasedMethod.
76 
77  virtual void lsape_set_default_options_() final;
78 
79  virtual std::string lsape_valid_options_string_() const final;
80 
81  virtual bool lsape_parse_option_(const std::string & option, const std::string & arg) final;
82 
83  virtual void lsape_init_graph_(const GEDGraph & graph) final;
84 
85  virtual void lsape_init_() final;
86 
87  virtual void lsape_populate_instance_(const GEDGraph & g, const GEDGraph & h, DMatrix & master_problem) final;
88 
89  virtual void lsape_pre_graph_init_(bool called_at_runtime) final;
90 
91  // Helper member functions.
92 
93  double compute_substitution_cost_(const GEDGraph & g, const GEDGraph & h, GEDGraph::NodeID i, GEDGraph::NodeID k, GEDMethod<UserNodeLabel, UserEdgeLabel> * exact_method) const;
94 
95  double compute_deletion_cost_(const GEDGraph & g, GEDGraph::NodeID i) const;
96 
97  double compute_insertion_cost_(const GEDGraph & h, GEDGraph::NodeID k) const;
98 
99  void build_subgraphs_(const GEDGraph & graph);
100 
101  void build_subgraph_(const GEDGraph & graph, GEDGraph::NodeID node);
102 
103  GEDGraph::GraphID subgraph_id_(const GEDGraph & graph, GEDGraph::NodeID node) const;
104 
105  void build_subgraph_dfs_(const GEDGraph & graph, GEDGraph::NodeID current_node, std::size_t depth_current_node, GEDGraph::NodeNodeMap & ids_in_subgraph, GEDGraph & subgraph);
106 
107  bool load_config_file_() const;
108 
109  GEDMethod<UserNodeLabel, UserEdgeLabel> * exact_method_factory_() const;
110 
111 };
112 
113 }
114 
115 #endif /* SRC_METHODS_SUBGRAPH_HPP_ */
std::map< NodeID, NodeID > NodeNodeMap
Map that assigns node IDs to node IDs.
Definition: ged_graph.hpp:114
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: subgraph.ipp:70
Contains the standardized input data along with basic functionality.
Definition: ged_data.hpp:55
std::vector< GEDGraph >::size_type GraphID
Type of internally used graph IDs.
Definition: ged_graph.hpp:112
virtual void lsape_populate_instance_(const GEDGraph &g, const GEDGraph &h, DMatrix &master_problem) final
Populates the LSAPE instance.
Definition: subgraph.ipp:174
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: subgraph.ipp:77
Abstract class for the (suboptimal) computation of the graph edit distance.
Definition: ged_method.hpp:40
GEDMethod
Selects the method.
virtual void lsape_init_() final
Initializes the method after initializing the global variables for the graphs.
Definition: subgraph.ipp:253
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: subgraph.ipp:204
Global namespace for GEDLIB.
Computes upper bounds for general edit costs.
Definition: subgraph.hpp:49
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: subgraph.ipp:57
std::size_t NodeID
Internally used vertex ID type.
Definition: ged_graph.hpp:108
virtual void lsape_pre_graph_init_(bool called_at_runtime) final
Initializes the method at runtime or during initialization before initializing the global variables f...
Definition: subgraph.ipp:239