GEDLIB  1.0
node.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_METHODS_NODE_IPP_
28 #define SRC_METHODS_NODE_IPP_
29 
30 namespace ged {
31 
32 // === Definitions of destructor and constructor. ===
33 template<class UserNodeLabel, class UserEdgeLabel>
34 Node<UserNodeLabel, UserEdgeLabel>::
35 ~Node() {}
36 
37 template<class UserNodeLabel, class UserEdgeLabel>
38 Node<UserNodeLabel, UserEdgeLabel>::
39 Node(const GEDData<UserNodeLabel, UserEdgeLabel> & ged_data) :
40 LSAPEBasedMethod<UserNodeLabel, UserEdgeLabel>(ged_data) {}
41 
42 // === Definitions of member functions inherited from LSAPEBasedMethod. ===
43 template<class UserNodeLabel, class UserEdgeLabel>
44 void
46 lsape_populate_instance_(const GEDGraph & g, const GEDGraph & h, DMatrix & master_problem) {
47 
48 #ifdef _OPENMP
49  omp_set_num_threads(this->num_threads_ - 1);
50 #pragma omp parallel for if(this->num_threads_ > 1)
51 #endif
52  for (std::size_t row_in_master = 0; row_in_master < master_problem.num_rows(); row_in_master++) {
53  for (std::size_t col_in_master = 0; col_in_master < master_problem.num_cols(); col_in_master++) {
54  if ((row_in_master < g.num_nodes()) and (col_in_master < h.num_nodes())) {
55  master_problem(row_in_master, col_in_master) = this->ged_data_.node_cost(g.get_node_label(row_in_master), h.get_node_label(col_in_master));
56  }
57  else if (row_in_master < g.num_nodes()) {
58  master_problem(row_in_master, h.num_nodes()) = this->ged_data_.node_cost(g.get_node_label(row_in_master), dummy_label());
59  }
60  else if (col_in_master < h.num_nodes()) {
61  master_problem(g.num_nodes(), col_in_master) = this->ged_data_.node_cost(dummy_label(), h.get_node_label(col_in_master));
62  }
63  }
64  }
65 }
66 
67 }
68 
69 #endif /* SRC_METHODS_NODE_IPP_ */
std::size_t num_nodes() const
Returns the number of nodes.
Definition: ged_graph.ipp:211
std::size_t num_threads_
The number of threads to be used.
const GEDData< UserNodeLabel, UserEdgeLabel > & ged_data_
The data on which the method is run.
Definition: ged_method.hpp:124
virtual void lsape_populate_instance_(const GEDGraph &g, const GEDGraph &h, DMatrix &master_problem) final
Populates the LSAPE instance.
Definition: node.ipp:46
std::size_t num_cols() const
Returns the number of columns.
Definition: matrix.ipp:110
LabelID get_node_label(NodeID node) const
Returns the label of a given node.
Definition: ged_graph.ipp:126
The normalized input graphs used by GEDLIB. All labels are integers.
Definition: ged_graph.hpp:104
constexpr LabelID dummy_label()
Returns a dummy label.
Global namespace for GEDLIB.
std::size_t num_rows() const
Returns the number of rows.
Definition: matrix.ipp:85