GEDLIB  1.0
constant.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_CONSTANT_IPP_
28 #define SRC_EDIT_COSTS_CONSTANT_IPP_
29 
30 namespace ged {
31 
32 template<class UserNodeLabel, class UserEdgeLabel>
33 Constant<UserNodeLabel, UserEdgeLabel>::
34 ~Constant() {}
35 
36 template<class UserNodeLabel, class UserEdgeLabel>
38 Constant(double node_ins_cost, double node_del_cost, double node_rel_cost, double edge_ins_cost, double edge_del_cost, double edge_rel_cost) :
39 node_ins_cost_{node_ins_cost},
40 node_del_cost_{node_del_cost},
41 node_rel_cost_{node_rel_cost},
42 edge_ins_cost_{edge_ins_cost},
43 edge_del_cost_{edge_del_cost},
44 edge_rel_cost_{edge_rel_cost} {}
45 
46 template<class UserNodeLabel, class UserEdgeLabel>
47 double
49 node_ins_cost_fun(const UserNodeLabel & node_label) const {
50  return node_ins_cost_;
51 }
52 
53 template<class UserNodeLabel, class UserEdgeLabel>
54 double
56 node_del_cost_fun(const UserNodeLabel & node_label) const {
57  return node_del_cost_;
58 }
59 
60 template<class UserNodeLabel, class UserEdgeLabel>
61 double
63 node_rel_cost_fun(const UserNodeLabel & node_label_1, const UserNodeLabel & node_label_2) const {
64  if (node_label_1 != node_label_2) {
65  return node_rel_cost_;
66  }
67  return 0.0;
68 }
69 
70 template<class UserNodeLabel, class UserEdgeLabel>
71 double
73 edge_ins_cost_fun(const UserEdgeLabel & edge_label) const {
74  return edge_ins_cost_;
75 }
76 
77 template<class UserNodeLabel, class UserEdgeLabel>
78 double
80 edge_del_cost_fun(const UserEdgeLabel & edge_label) const {
81  return edge_del_cost_;
82 }
83 
84 template<class UserNodeLabel, class UserEdgeLabel>
85 double
87 edge_rel_cost_fun(const UserEdgeLabel & edge_label_1, const UserEdgeLabel & edge_label_2) const {
88  if (edge_label_1 != edge_label_2) {
89  return edge_rel_cost_;
90  }
91  return 0.0;
92 }
93 
94 }
95 
96 #endif /* SRC_EDIT_COSTS_CONSTANT_IPP_ */
virtual double node_del_cost_fun(const UserNodeLabel &node_label) const final
Node deletion cost function.
Definition: constant.ipp:56
virtual double node_rel_cost_fun(const UserNodeLabel &node_label_1, const UserNodeLabel &node_label_2) const final
Node relabeling cost function.
Definition: constant.ipp:63
virtual double edge_rel_cost_fun(const UserEdgeLabel &edge_label_1, const UserEdgeLabel &edge_label_2) const final
Edge relabeling cost function.
Definition: constant.ipp:87
virtual double edge_ins_cost_fun(const UserEdgeLabel &edge_label) const final
Edge insertion cost function.
Definition: constant.ipp:73
Global namespace for GEDLIB.
virtual double node_ins_cost_fun(const UserNodeLabel &node_label) const final
Node insertions cost function.
Definition: constant.ipp:49
Constant(double node_ins_cost=1, double node_del_cost=1, double node_rel_cost=1, double edge_ins_cost=1, double edge_del_cost=1, double edge_rel_cost=1)
Constructor.
Definition: constant.ipp:38
virtual double edge_del_cost_fun(const UserEdgeLabel &edge_label) const final
Edge deletion cost function.
Definition: constant.ipp:80