GEDLIB  1.0
cmu.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_CMU_IPP_
28 #define SRC_EDIT_COSTS_CMU_IPP_
29 
30 namespace ged {
31 
32 template<>
33 CMU<GXLLabel, GXLLabel>::
34 ~CMU() {}
35 
36 template<>
38 CMU(double node_ins_del_cost, double alpha) :
39 node_ins_del_cost_{node_ins_del_cost},
40 alpha_{alpha} {}
41 
42 template<>
43 double
45 node_ins_cost_fun(const GXLLabel & node_label) const {
46  return alpha_ * node_ins_del_cost_;
47 }
48 
49 template<>
50 double
52 node_del_cost_fun(const GXLLabel & node_label) const {
53  return alpha_ * node_ins_del_cost_;
54 }
55 
56 template<>
57 double
59 node_rel_cost_fun(const GXLLabel & node_label_1, const GXLLabel & node_label_2) const {
60  return 0.0;
61 }
62 
63 template<>
64 void
66 vectorize_node_label(const GXLLabel & node_label, std::vector<double> & vector_representation) const {
67  vector_representation.clear();
68  vector_representation.push_back(std::stod(node_label.at("x")));
69  vector_representation.push_back(std::stod(node_label.at("y")));
70 }
71 
72 template<>
73 double
75 edge_ins_cost_fun(const GXLLabel & edge_label) const {
76  return (1 - alpha_) * std::stod(edge_label.at("dist"));
77 }
78 
79 template<>
80 double
82 edge_del_cost_fun(const GXLLabel & edge_label) const {
83  return (1 - alpha_) * std::stod(edge_label.at("dist"));
84 }
85 
86 template<>
87 double
89 edge_rel_cost_fun(const GXLLabel & edge_label_1, const GXLLabel & edge_label_2) const {
90  return (1 - alpha_) * std::abs(std::stod(edge_label_1.at("dist")) - std::stod(edge_label_2.at("dist")));
91 }
92 
93 }
94 
95 #endif /* SRC_EDIT_COSTS_CMU_IPP_ */
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.
virtual double edge_ins_cost_fun(const UserEdgeLabel &edge_label) const final
Edge insertion cost function.
virtual double node_del_cost_fun(const UserNodeLabel &node_label) const final
Node deletion cost function.
CMU(double node_ins_del_cost=100000, double alpha=0.5)
Constructor.
std::map< std::string, std::string > GXLLabel
Type of node and edge labels of graphs given in the .gxl file format.
virtual void vectorize_node_label(const UserNodeLabel &node_label, std::vector< double > &vector_representation) const final
Computes a node label&#39;s representation as a real-valued vector.
Global namespace for GEDLIB.
virtual double node_rel_cost_fun(const UserNodeLabel &node_label_1, const UserNodeLabel &node_label_2) const final
Node relabeling cost function.
virtual double edge_rel_cost_fun(const UserEdgeLabel &edge_label_1, const UserEdgeLabel &edge_label_2) const final
Edge relabeling cost function.