GEDLIB  1.0
grec_1.ipp
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_EDIT_COSTS_GREC_1_IPP_
28 #define SRC_EDIT_COSTS_GREC_1_IPP_
29 
30 
31 namespace ged {
32 
33 template<>
34 GREC1<GXLLabel, GXLLabel>::
35 ~GREC1() {}
36 
37 template<>
39 GREC1() {}
40 
41 template<>
42 double
44 node_ins_cost_fun(const GXLLabel & node_label) const {
45  return 45;
46 }
47 
48 template<>
49 double
51 node_del_cost_fun(const GXLLabel & node_label) const {
52  return 45;
53 }
54 
55 template<>
56 double
58 node_rel_cost_fun(const GXLLabel & node_label_1, const GXLLabel & node_label_2) const {
59  if (node_label_1.at("type") != node_label_2.at("type")) {
60  return 90;
61  }
62  double x_l_minus_x_r(std::stod(node_label_1.at("x")) - std::stod(node_label_2.at("x")));
63  double y_l_minus_y_r(std::stod(node_label_1.at("y")) - std::stod(node_label_2.at("y")));
64  return 0.5 * std::sqrt(std::pow(x_l_minus_x_r, 2) + std::pow(y_l_minus_y_r, 2));
65 }
66 
67 template<>
68 double
70 edge_ins_cost_fun(const GXLLabel & edge_label) const {
71  return 7.5 * std::stod(edge_label.at("frequency"));
72 }
73 
74 template<>
75 double
77 edge_del_cost_fun(const GXLLabel & edge_label) const {
78  return 7.5 * std::stod(edge_label.at("frequency"));
79 }
80 
81 template<>
82 double
84 edge_rel_cost_fun(const GXLLabel & edge_label_1, const GXLLabel & edge_label_2) const {
85  if (edge_label_1.at("frequency") != edge_label_2.at("frequency")) {
86  return 7.5;
87  }
88  if (edge_label_1.at("frequency") == "1") {
89  if (edge_label_1.at("type0") == edge_label_2.at("type0")) {
90  return 0;
91  }
92  return 15;
93  }
94  return 0;
95 }
96 
97 }
98 
99 
100 #endif /* SRC_EDIT_COSTS_GREC_1_IPP_ */
virtual double edge_rel_cost_fun(const UserEdgeLabel &edge_label_1, const UserEdgeLabel &edge_label_2) const final
Edge relabeling cost function.
GREC1()
Constructor.
virtual double node_del_cost_fun(const UserNodeLabel &node_label) const final
Node deletion cost function.
virtual double node_rel_cost_fun(const UserNodeLabel &node_label_1, const UserNodeLabel &node_label_2) const final
Node relabeling cost function.
std::map< std::string, std::string > GXLLabel
Type of node and edge labels of graphs given in the .gxl file format.
Global namespace for GEDLIB.
virtual double edge_ins_cost_fun(const UserEdgeLabel &edge_label) const final
Edge insertion cost function.
virtual double node_ins_cost_fun(const UserNodeLabel &node_label) const final
Node insertions cost function.
virtual double edge_del_cost_fun(const UserEdgeLabel &edge_label) const final
Edge deletion cost function.