27 #ifndef SRC_EDIT_COSTS_GREC_2_IPP_ 28 #define SRC_EDIT_COSTS_GREC_2_IPP_ 33 GREC2<GXLLabel, GXLLabel>::
38 GREC2(
double node_ins_del_cost,
double edge_ins_del_cost,
double alpha) :
39 node_ins_del_cost_{node_ins_del_cost},
40 edge_ins_del_cost_{edge_ins_del_cost},
47 return alpha_ * node_ins_del_cost_;
54 return alpha_ * node_ins_del_cost_;
61 if (node_label_1.at(
"type") != node_label_2.at(
"type")) {
62 return alpha_ * 2 * node_ins_del_cost_;
64 double x_l_minus_x_r(std::stod(node_label_1.at(
"x")) - std::stod(node_label_2.at(
"x")));
65 double y_l_minus_y_r(std::stod(node_label_1.at(
"y")) - std::stod(node_label_2.at(
"y")));
66 return alpha_ * std::sqrt(std::pow(x_l_minus_x_r, 2) + std::pow(y_l_minus_y_r, 2));
73 return (1 - alpha_) * edge_ins_del_cost_ * std::stod(edge_label.at(
"frequency"));
80 return (1 - alpha_) * edge_ins_del_cost_ * std::stod(edge_label.at(
"frequency"));
87 DMatrix edge_rel_cost_matrix(std::stoul(edge_label_1.at(
"frequency")) + 1, std::stoul(edge_label_2.at(
"frequency")) + 1);
88 for (std::size_t i{0}; i < edge_rel_cost_matrix.num_rows() - 1; i++) {
89 edge_rel_cost_matrix(i, edge_rel_cost_matrix.num_cols() - 1) = edge_ins_del_cost_;
91 for (std::size_t k{0}; k < edge_rel_cost_matrix.num_cols() - 1; k++) {
92 edge_rel_cost_matrix(edge_rel_cost_matrix.num_rows() - 1, k) = edge_ins_del_cost_;
94 for (std::size_t i{0}; i < edge_rel_cost_matrix.num_rows() - 1; i++) {
95 for (std::size_t k{0}; k < edge_rel_cost_matrix.num_cols() - 1; k++) {
96 if (edge_label_1.at(std::string(
"type") + std::to_string(i)) == edge_label_2.at(std::string(
"type") + std::to_string(k))) {
97 edge_rel_cost_matrix(i, k) = 0;
100 edge_rel_cost_matrix(i, k) = 2 * edge_ins_del_cost_;
104 LSAPESolver lsape_solver(&edge_rel_cost_matrix);
105 lsape_solver.solve();
106 return (1 - alpha_) * lsape_solver.minimal_cost();
virtual double edge_del_cost_fun(const UserEdgeLabel &edge_label) const final
Edge deletion cost function.
virtual double edge_rel_cost_fun(const UserEdgeLabel &edge_label_1, const UserEdgeLabel &edge_label_2) const final
Edge relabeling cost function.
GREC2(double node_ins_del_cost=90, double edge_ins_del_cost=15, double alpha=0.5)
Constructor.
virtual double node_rel_cost_fun(const UserNodeLabel &node_label_1, const UserNodeLabel &node_label_2) const final
Node relabeling cost function.
Matrix< double > DMatrix
Matrix with double entries.
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.
Global namespace for GEDLIB.
virtual double node_ins_cost_fun(const UserNodeLabel &node_label) const final
Node insertions cost function.
virtual double edge_ins_cost_fun(const UserEdgeLabel &edge_label) const final
Edge insertion cost function.