GEDLIB  1.0
fingerprint.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_FINGERPRINT_IPP_
28 #define SRC_EDIT_COSTS_FINGERPRINT_IPP_
29 
30 
31 namespace ged {
32 
33 template<>
34 Fingerprint<GXLLabel, GXLLabel>::
35 ~Fingerprint() {}
36 
37 template<>
39 Fingerprint(double node_ins_del_cost, double edge_ins_del_cost, double alpha) :
40 node_ins_del_cost_{node_ins_del_cost},
41 edge_ins_del_cost_{edge_ins_del_cost},
42 alpha_{alpha} {}
43 
44 template<>
45 double
47 node_ins_cost_fun(const GXLLabel & node_label) const {
48  return alpha_ * node_ins_del_cost_;
49 }
50 
51 template<>
52 double
54 node_del_cost_fun(const GXLLabel & node_label) const {
55  return alpha_ * node_ins_del_cost_;
56 }
57 
58 template<>
59 double
61 node_rel_cost_fun(const GXLLabel & node_label_1, const GXLLabel & node_label_2) const {
62  return 0;
63 }
64 
65 template<>
66 double
68 edge_ins_cost_fun(const GXLLabel & edge_label) const {
69  return (1 - alpha_) * edge_ins_del_cost_;
70 }
71 
72 template<>
73 double
75 edge_del_cost_fun(const GXLLabel & edge_label) const {
76  return (1 - alpha_) * edge_ins_del_cost_;
77 }
78 
79 template<>
80 double
82 edge_rel_cost_fun(const GXLLabel & edge_label_1, const GXLLabel & edge_label_2) const {
83  double orient_diff{std::fabs(std::stod(edge_label_1.at("orient")) - std::stod(edge_label_2.at("orient")))};
84  return (1 - alpha_) * std::min(pi_() - orient_diff, orient_diff);
85 }
86 
87 }
88 
89 
90 #endif /* SRC_EDIT_COSTS_FINGERPRINT_IPP_ */
Fingerprint(double node_ins_del_cost=0.7, double edge_ins_del_cost=0.5, double alpha=0.75)
Constructor.
virtual double edge_rel_cost_fun(const UserEdgeLabel &edge_label_1, const UserEdgeLabel &edge_label_2) const final
Edge relabeling cost function.
virtual double edge_ins_cost_fun(const UserEdgeLabel &edge_label) const final
Edge insertion cost function.
std::map< std::string, std::string > GXLLabel
Type of node and edge labels of graphs given in the .gxl file format.
virtual double node_del_cost_fun(const UserNodeLabel &node_label) const final
Node deletion cost function.
virtual double edge_del_cost_fun(const UserEdgeLabel &edge_label) const final
Edge 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.
Global namespace for GEDLIB.
virtual double node_ins_cost_fun(const UserNodeLabel &node_label) const final
Node insertions cost function.