27 #ifndef SRC_ENV_GED_DATA_IPP_ 28 #define SRC_ENV_GED_DATA_IPP_ 32 template<
class UserNodeLabel,
class UserEdgeLabel>
33 GEDData<UserNodeLabel, UserEdgeLabel>::
38 num_graphs_without_shuffled_copies_{0},
39 strings_to_internal_node_ids_(),
40 internal_node_ids_to_strings_(),
47 delete_edit_costs_{
true},
51 template<
class UserNodeLabel,
class UserEdgeLabel>
54 if (delete_edit_costs_) {
59 template<
class UserNodeLabel,
class UserEdgeLabel>
63 if (delete_edit_costs_) {
68 if (edit_cost_constants.size() == 6) {
69 edit_costs_ =
new Constant<UserNodeLabel, UserEdgeLabel>(edit_cost_constants.at(0), edit_cost_constants.at(1), edit_cost_constants.at(2), edit_cost_constants.at(3), edit_cost_constants.at(4), edit_cost_constants.at(5));
71 else if (edit_cost_constants.size() == 0) {
75 throw Error(
"Wrong number of constants for selected edit costs ged::Options::EditCosts::CONSTANT. Expected: 6 or 0; actual: " + std::to_string(edit_cost_constants.size()) +
".");
79 throw Error(
"Selected edit costs unavailable for template parameters UserNodeLabel = " + std::string(
typeid(UserNodeLabel).name()) +
" and UserEdgeLabel = " + std::string(
typeid(UserEdgeLabel).name()) +
".");
81 delete_edit_costs_ =
true;
88 if (delete_edit_costs_) {
93 if (edit_cost_constants.size() == 4) {
94 edit_costs_ =
new CHEM1<GXLLabel, GXLLabel>(edit_cost_constants.at(0), edit_cost_constants.at(1), edit_cost_constants.at(2), edit_cost_constants.at(3));
96 else if (edit_cost_constants.size() == 0) {
100 throw Error(
"Wrong number of constants for selected edit costs ged::Options::EditCosts::CHEM_1. Expected: 4 or 0; actual: " + std::to_string(edit_cost_constants.size()) +
".");
104 if (edit_cost_constants.size() == 3) {
105 edit_costs_ =
new CHEM2<GXLLabel, GXLLabel>(edit_cost_constants.at(0), edit_cost_constants.at(1), edit_cost_constants.at(2));
107 else if (edit_cost_constants.size() == 0) {
111 throw Error(
"Wrong number of constants for selected edit costs ged::Options::EditCosts::CHEM_2. Expected: 3 or 0; actual: " + std::to_string(edit_cost_constants.size()) +
".");
115 if (edit_cost_constants.size() == 0) {
119 throw Error(
"Wrong number of constants for selected edit costs ged::Options::EditCosts::GREC_1. Expected: 0; actual: " + std::to_string(edit_cost_constants.size()) +
".");
123 if (edit_cost_constants.size() == 3) {
124 edit_costs_ =
new GREC2<GXLLabel, GXLLabel>(edit_cost_constants.at(0), edit_cost_constants.at(1), edit_cost_constants.at(2));
126 else if (edit_cost_constants.size() == 0) {
130 throw Error(
"Wrong number of constants for selected edit costs ged::Options::EditCosts::GREC_2. Expected: 3 or 0; actual: " + std::to_string(edit_cost_constants.size()) +
".");
134 if (edit_cost_constants.size() == 3) {
137 else if (edit_cost_constants.size() == 0) {
141 throw Error(
"Wrong number of constants for selected edit costs ged::Options::EditCosts::PROTEIN. Expected: 3 or 0; actual: " + std::to_string(edit_cost_constants.size()) +
".");
145 if (edit_cost_constants.size() == 3) {
148 else if (edit_cost_constants.size() == 0) {
152 throw Error(
"Wrong number of constants for selected edit costs ged::Options::EditCosts::FINGERPRINT. Expected: 3 or 0; actual: " + std::to_string(edit_cost_constants.size()) +
".");
156 if (edit_cost_constants.size() == 3) {
157 edit_costs_ =
new Letter<GXLLabel, GXLLabel>(edit_cost_constants.at(0), edit_cost_constants.at(1), edit_cost_constants.at(2));
159 else if (edit_cost_constants.size() == 0) {
163 throw Error(
"Wrong number of constants for selected edit costs ged::Options::EditCosts::LETTER. Expected: 3 or 0; actual: " + std::to_string(edit_cost_constants.size()) +
".");
167 if (edit_cost_constants.size() == 2) {
170 else if (edit_cost_constants.size() == 0) {
174 throw Error(
"Wrong number of constants for selected edit costs ged::Options::EditCosts::CMU. Expected: 2 or 0; actual: " + std::to_string(edit_cost_constants.size()) +
".");
178 if (edit_cost_constants.size() == 6) {
179 edit_costs_ =
new Constant<GXLLabel, GXLLabel>(edit_cost_constants.at(0), edit_cost_constants.at(1), edit_cost_constants.at(2), edit_cost_constants.at(3), edit_cost_constants.at(4), edit_cost_constants.at(5));
181 else if (edit_cost_constants.size() == 0) {
185 throw Error(
"Wrong number of constants for selected edit costs ged::Options::EditCosts::CONSTANT. Expected: 6 or 0; actual: " + std::to_string(edit_cost_constants.size()) +
".");
189 delete_edit_costs_ =
true;
192 template<
class UserNodeLabel,
class UserEdgeLabel>
196 if (delete_edit_costs_) {
199 edit_costs_ = edit_costs;
200 delete_edit_costs_ =
false;
203 template<
class UserNodeLabel,
class UserEdgeLabel>
208 for (
auto itr = node_labels_.begin(); itr != node_labels_.end(); itr++) {
209 if (*itr == node_label)
return (
id + 1);
212 node_labels_.push_back(node_label);
216 template<
class UserNodeLabel,
class UserEdgeLabel>
220 if ((label_id > node_labels_.size()) or (label_id == 0)) {
221 throw Error(
"Invalid node label ID " + std::to_string(label_id) +
".");
223 return node_labels_.at(label_id - 1);
226 template<
class UserNodeLabel,
class UserEdgeLabel>
231 for (
auto itr = edge_labels_.begin(); itr != edge_labels_.end(); itr++) {
232 if (*itr == edge_label)
return (
id + 1);
235 edge_labels_.push_back(edge_label);
239 template<
class UserNodeLabel,
class UserEdgeLabel>
243 if ((label_id > edge_labels_.size()) or (label_id == 0)) {
244 throw Error(
"Invalid edge label ID " + std::to_string(label_id) +
".");
246 return edge_labels_.at(label_id - 1);
249 template<
class UserNodeLabel,
class UserEdgeLabel>
256 template<
class UserNodeLabel,
class UserEdgeLabel>
262 std::size_t size_old_node_costs = node_costs_.
num_rows();
263 if (size_old_node_costs < node_labels_.size() + 1) {
264 DMatrix old_node_costs(node_costs_);
265 node_costs_.
resize(node_labels_.size() + 1, node_labels_.size() + 1);
266 for (
LabelID l_id_lhs = 0; l_id_lhs < node_labels_.size() + 1; l_id_lhs++) {
267 for (
LabelID l_id_rhs = 0; l_id_rhs < node_labels_.size() + 1; l_id_rhs++) {
268 if (l_id_lhs < size_old_node_costs and l_id_rhs < size_old_node_costs) {
269 node_costs_(l_id_lhs, l_id_rhs) = old_node_costs(l_id_lhs, l_id_rhs);
271 else if (l_id_lhs == l_id_rhs) {
272 node_costs_(l_id_lhs, l_id_rhs) = 0.0;
275 node_costs_(l_id_lhs, l_id_rhs) = edit_costs_->node_ins_cost_fun(node_labels_.at(l_id_rhs - 1));
278 node_costs_(l_id_lhs, l_id_rhs) = edit_costs_->node_del_cost_fun(node_labels_.at(l_id_lhs - 1));
281 node_costs_(l_id_lhs, l_id_rhs) = edit_costs_->node_rel_cost_fun(node_labels_.at(l_id_lhs - 1), node_labels_.at(l_id_rhs - 1));
288 std::size_t size_old_edge_costs = edge_costs_.
num_rows();
289 if (size_old_edge_costs < edge_labels_.size() + 1) {
290 DMatrix old_edge_costs(edge_costs_);
291 edge_costs_.
resize(edge_labels_.size() + 1, edge_labels_.size() + 1);
292 for (
LabelID l_id_lhs = 0; l_id_lhs < edge_labels_.size() + 1; l_id_lhs++) {
293 for (
LabelID l_id_rhs = 0; l_id_rhs < edge_labels_.size() + 1; l_id_rhs++) {
294 if (l_id_lhs < size_old_edge_costs and l_id_rhs < size_old_edge_costs) {
295 edge_costs_(l_id_lhs, l_id_rhs) = old_edge_costs(l_id_lhs, l_id_rhs);
297 else if (l_id_lhs == l_id_rhs) {
298 edge_costs_(l_id_lhs, l_id_rhs) = 0.0;
301 edge_costs_(l_id_lhs, l_id_rhs) = edit_costs_->edge_ins_cost_fun(edge_labels_.at(l_id_rhs - 1));
304 edge_costs_(l_id_lhs, l_id_rhs) = edit_costs_->edge_del_cost_fun(edge_labels_.at(l_id_lhs - 1));
307 edge_costs_(l_id_lhs, l_id_rhs) = edit_costs_->edge_rel_cost_fun(edge_labels_.at(l_id_lhs - 1), edge_labels_.at(l_id_rhs - 1));
315 template<
class UserNodeLabel,
class UserEdgeLabel>
319 return graphs_.size();
322 template<
class UserNodeLabel,
class UserEdgeLabel>
326 return graphs_.at(graph_id);
329 template<
class UserNodeLabel,
class UserEdgeLabel>
333 if (
string ==
"DUMMY") {
336 return strings_to_internal_node_ids_.at(graph_id).at(
string);
339 template<
class UserNodeLabel,
class UserEdgeLabel>
346 return internal_node_ids_to_strings_.at(graph_id).at(node_id);
349 template<
class UserNodeLabel,
class UserEdgeLabel>
356 template<
class UserNodeLabel,
class UserEdgeLabel>
360 return num_graphs_without_shuffled_copies_;
363 template<
class UserNodeLabel,
class UserEdgeLabel>
368 throw Error(
"No shuffled copy available.");
376 template<
class UserNodeLabel,
class UserEdgeLabel>
383 template<
class UserNodeLabel,
class UserEdgeLabel>
384 std::vector<GEDGraph>::const_iterator
387 return graphs_.cbegin();
390 template<
class UserNodeLabel,
class UserEdgeLabel>
391 std::vector<GEDGraph>::const_iterator
394 return graphs_.cend();
397 template<
class UserNodeLabel,
class UserEdgeLabel>
404 template<
class UserNodeLabel,
class UserEdgeLabel>
411 template<
class UserNodeLabel,
class UserEdgeLabel>
415 return max_num_nodes_;
418 template<
class UserNodeLabel,
class UserEdgeLabel>
422 return max_num_edges_;
425 template<
class UserNodeLabel,
class UserEdgeLabel>
430 return edge_costs_(label1, label2);
432 if (label1 == label2) {
436 return edit_costs_->edge_ins_cost_fun(edge_labels_.at(label2 - 1));
439 return edit_costs_->edge_del_cost_fun(edge_labels_.at(label1 - 1));
441 return edit_costs_->edge_rel_cost_fun(edge_labels_.at(label1 - 1), edge_labels_.at(label2 - 1));
444 template<
class UserNodeLabel,
class UserEdgeLabel>
448 edit_costs_->vectorize_edge_label(edge_labels_.at(edge_label - 1), vector_representation);
451 template<
class UserNodeLabel,
class UserEdgeLabel>
456 return node_costs_(label1, label2);
458 if (label1 == label2) {
462 return edit_costs_->node_ins_cost_fun(node_labels_.at(label2 - 1));
465 return edit_costs_->node_del_cost_fun(node_labels_.at(label1 - 1));
467 return edit_costs_->node_rel_cost_fun(node_labels_.at(label1 - 1), node_labels_.at(label2 - 1));
470 template<
class UserNodeLabel,
class UserEdgeLabel>
474 edit_costs_->vectorize_node_label(node_labels_.at(node_label - 1), vector_representation);
477 template<
class UserNodeLabel,
class UserEdgeLabel>
483 ofs.open(filename, std::ofstream::out | std::ofstream::app);
486 ofs.open(filename, std::ofstream::out);
488 ofs << graph_names_.at(g_id) <<
" " << graph_names_.at(h_id);
489 std::vector<NodeMap::Assignment> relation;
491 for (
const auto & assignment : relation) {
492 ofs <<
" " << node_id_to_string_(g_id, assignment.first) <<
"," << node_id_to_string_(h_id, assignment.second);
498 template<
class UserNodeLabel,
class UserEdgeLabel>
502 std::string prefix(graph_names_.at(g_id) +
" " + graph_names_.at(h_id) +
" ");
503 std::ifstream ifs(filename);
504 if (not ifs.good()) {
505 throw Error(
"Loading node map from file " + filename +
" failed. File cannot be opened.");
508 bool contains_node_map{
false};
509 while(std::getline(ifs, line)) {
510 auto res = std::mismatch(prefix.begin(), prefix.end(), line.begin());
511 if (res.first == prefix.end()) {
512 contains_node_map =
true;
513 line = line.substr(prefix.size());
518 if (not contains_node_map) {
519 throw Error(
"Loading node map from file " + filename +
" failed. File does not contain a node map between the graphs " + graph_names_.at(g_id) +
" and " + graph_names_.at(h_id) +
".");
521 std::istringstream line_stream(line);
522 std::string assignment;
523 std::string node_in_g;
524 std::string node_in_h;
525 while (std::getline(line_stream, assignment,
' ')) {
526 std::istringstream assignment_stream(assignment);
527 if (not std::getline(assignment_stream, node_in_g,
',')) {
528 throw Error(
"Loading node map from file " + filename +
" failed. File has the wrong format. Expected format of lines: \"<graph name 1> <graph name 2> [<original node ID 1>,<original node ID 2>] [...]\"");
530 if (not std::getline(assignment_stream, node_in_h,
',')) {
531 throw Error(
"Loading node map from file " + filename +
" failed. File has the wrong format. Expected format of lines: \"<graph name 1> <graph name 2> [<original node ID 1>,<original node ID 2>] [...]\"");
533 node_map.
add_assignment(string_to_node_id_(g_id, node_in_g), string_to_node_id_(h_id, node_in_h));
537 template<
class UserNodeLabel,
class UserEdgeLabel>
544 for (
auto node = g.
nodes().first; node != g.
nodes().second; node++) {
547 for (
auto node = h.
nodes().first; node != h.
nodes().second; node++) {
555 for (
auto ij = g.
edges().first; ij != g.
edges().second; ij++) {
558 for (
auto kl = h.
edges().first; kl != h.
edges().second; kl++) {
567 template<
class UserNodeLabel,
class UserEdgeLabel>
579 std::vector<GEDGraph::EdgeID> incident_edges_i_j;
582 if (g.
head(*edge) != j) {
583 incident_edges_i_j.push_back(*edge);
589 if (g.
head(*edge) != i) {
590 incident_edges_i_j.push_back(*edge);
596 std::vector<GEDGraph::EdgeID> incident_edges_k_l;
599 if (h.
head(*edge) != l) {
600 incident_edges_k_l.push_back(*edge);
606 if (h.
head(*edge) != k) {
607 incident_edges_k_l.push_back(*edge);
622 for (
const auto & edge : incident_edges_i_j) {
625 for (
const auto & edge : incident_edges_k_l) {
636 for (
const auto & edge : incident_edges_i_j) {
639 for (
const auto & edge : incident_edges_k_l) {
653 template<
class UserNodeLabel,
class UserEdgeLabel>
666 template<
class UserNodeLabel,
class UserEdgeLabel>
687 template<
class UserNodeLabel,
class UserEdgeLabel>
691 std::vector<LabelID> node_labels_g;
692 for (
auto node = g.
nodes().first; node != g.
nodes().second; node++) {
695 std::vector<LabelID> node_labels_h;
696 for (
auto node = h.
nodes().first; node != h.
nodes().second; node++) {
699 std::vector<LabelID> edge_labels_g;
700 for (
auto edge = g.
edges().first; edge != g.
edges().second; edge++) {
703 std::vector<LabelID> edge_labels_h;
704 for (
auto edge = h.
edges().first; edge != h.
edges().second; edge++) {
707 for (
auto label_1 : node_labels_g) {
708 for (
auto label_2 : node_labels_h) {
714 for (
auto label_1 : edge_labels_g) {
715 for (
auto label_2 : edge_labels_h) {
724 template<
class UserNodeLabel,
class UserEdgeLabel>
729 return node_costs_.
max();
731 double max_cost{std::numeric_limits<double>::min()};
734 max_cost = std::max(max_cost,
node_cost(label_1, label_2));
740 template<
class UserNodeLabel,
class UserEdgeLabel>
744 double max_cost{std::numeric_limits<double>::min()};
745 for (
auto node = graph.
nodes().first; node != graph.
nodes().second; node++) {
751 template<
class UserNodeLabel,
class UserEdgeLabel>
755 double min_cost{std::numeric_limits<double>::max()};
756 for (
auto node = graph.
nodes().first; node != graph.
nodes().second; node++) {
762 template<
class UserNodeLabel,
class UserEdgeLabel>
769 double mean_cost{0.0};
770 for (
auto node = graph.
nodes().first; node != graph.
nodes().second; node++) {
773 return mean_cost /
static_cast<double>(graph.
num_nodes());
776 template<
class UserNodeLabel,
class UserEdgeLabel>
780 double max_cost{std::numeric_limits<double>::min()};
781 for (
auto node = graph.
nodes().first; node != graph.
nodes().second; node++) {
787 template<
class UserNodeLabel,
class UserEdgeLabel>
791 double min_cost{std::numeric_limits<double>::max()};
792 for (
auto node = graph.
nodes().first; node != graph.
nodes().second; node++) {
798 template<
class UserNodeLabel,
class UserEdgeLabel>
805 double mean_cost{0.0};
806 for (
auto node = graph.
nodes().first; node != graph.
nodes().second; node++) {
809 return mean_cost /
static_cast<double>(graph.
num_nodes());
812 template<
class UserNodeLabel,
class UserEdgeLabel>
816 double max_cost{std::numeric_limits<double>::min()};
817 for (
auto node_g = g.
nodes().first; node_g != g.
nodes().second; node_g++) {
818 for (
auto node_h = h.
nodes().first; node_h != h.
nodes().second; node_h++) {
825 template<
class UserNodeLabel,
class UserEdgeLabel>
829 double min_cost{std::numeric_limits<double>::max()};
830 for (
auto node_g = g.
nodes().first; node_g != g.
nodes().second; node_g++) {
831 for (
auto node_h = h.
nodes().first; node_h != h.
nodes().second; node_h++) {
840 template<
class UserNodeLabel,
class UserEdgeLabel>
847 double mean_cost{0.0};
848 for (
auto node_g = g.
nodes().first; node_g != g.
nodes().second; node_g++) {
849 for (
auto node_h = h.
nodes().first; node_h != h.
nodes().second; node_h++) {
856 template<
class UserNodeLabel,
class UserEdgeLabel>
860 double max_cost{std::numeric_limits<double>::min()};
861 for (
auto egde_g = g.
edges().first; egde_g != g.
edges().second; egde_g++) {
862 for (
auto edge_h = h.
edges().first; edge_h != h.
edges().second; edge_h++) {
869 template<
class UserNodeLabel,
class UserEdgeLabel>
873 double min_cost{std::numeric_limits<double>::max()};
874 for (
auto egde_g = g.
edges().first; egde_g != g.
edges().second; egde_g++) {
875 for (
auto edge_h = h.
edges().first; edge_h != h.
edges().second; edge_h++) {
884 template<
class UserNodeLabel,
class UserEdgeLabel>
891 double mean_cost{0.0};
892 for (
auto edge_g = g.
edges().first; edge_g != g.
edges().second; edge_g++) {
893 for (
auto edge_h = h.
edges().first; edge_h != h.
edges().second; edge_h++) {
900 template<
class UserNodeLabel,
class UserEdgeLabel>
905 return edge_costs_.
max();
907 double max_cost{std::numeric_limits<double>::min()};
910 max_cost = std::max(max_cost,
edge_cost(label_1, label_2));
916 template<
class UserNodeLabel,
class UserEdgeLabel>
920 double max_cost{std::numeric_limits<double>::min()};
921 for (
auto edge = graph.
edges().first; edge != graph.
edges().second; edge++) {
927 template<
class UserNodeLabel,
class UserEdgeLabel>
934 double mean_cost{0.0};
935 for (
auto edge = graph.
edges().first; edge != graph.
edges().second; edge++) {
938 return mean_cost /
static_cast<double>(graph.
num_edges());
941 template<
class UserNodeLabel,
class UserEdgeLabel>
945 double min_cost{std::numeric_limits<double>::max()};
946 for (
auto edge = graph.
edges().first; edge != graph.
edges().second; edge++) {
952 template<
class UserNodeLabel,
class UserEdgeLabel>
956 double max_cost{std::numeric_limits<double>::min()};
957 for (
auto edge = graph.
edges().first; edge != graph.
edges().second; edge++) {
963 template<
class UserNodeLabel,
class UserEdgeLabel>
967 double min_cost{std::numeric_limits<double>::max()};
968 for (
auto edge = graph.
edges().first; edge != graph.
edges().second; edge++) {
974 template<
class UserNodeLabel,
class UserEdgeLabel>
981 double mean_cost{0.0};
982 for (
auto edge = graph.
edges().first; edge != graph.
edges().second; edge++) {
985 return mean_cost /
static_cast<double>(graph.
num_edges());
988 template<
class UserNodeLabel,
class UserEdgeLabel>
1001 template<
class UserNodeLabel,
class UserEdgeLabel>
1014 template<
class UserNodeLabel,
class UserEdgeLabel>
1024 template<
class UserNodeLabel,
class UserEdgeLabel>
1034 template<
class UserNodeLabel,
class UserEdgeLabel>
1044 template<
class UserNodeLabel,
class UserEdgeLabel>
std::size_t max_num_nodes() const
Returns maximal number of nodes.
double min_node_subs_cost(const GEDGraph &g, const GEDGraph &h) const
Returns the minimal cost of substituting a node contained in a graph by a node contained in another g...
std::size_t num_nodes() const
Returns the number of nodes.
Contains the standardized input data along with basic functionality.
void compute_induced_cost(const GEDGraph &g, const GEDGraph &h, NodeMap &node_map) const
Computes the edit cost between two graphs induced by a node map.
ScalarT max() const
Returns the maximal coefficient.
double edge_cost(LabelID label1, LabelID label2) const
Returns edge relabeling, insertion, or deletion cost.
Edit cost functions for the dataset GREC.
Edit cost functions for chemical graphs such as the ones contained in the datasets Mutagenicity...
void as_relation(std::vector< Assignment > &relation) const
Constructs the representation as relation.
Selects ged::Fingerprint.
double node_cost(LabelID label1, LabelID label2) const
Returns node relabeling, insertion, or deletion cost.
void resize(std::size_t num_rows, std::size_t num_cols)
Resizes the matrix.
double max_node_ins_cost(const GEDGraph &graph) const
Returns the maximal cost of inserting a node contained in a graph.
std::vector< GEDGraph >::size_type GraphID
Type of internally used graph IDs.
std::size_t max_num_edges() const
Returns maximal number of nodes.
NodeID head(EdgeID edge) const
Returns the head of an edge.
Lazy initialization, shuffled graph copies are constructed.
void swap_assignments(const NodeMap::Assignment &assignment_1, const NodeMap::Assignment &assignment_2, double swap_cost, NodeMap &node_map) const
Swaps two assignments in a node map.
bool is_edge(NodeID tail, NodeID head) const
Checks if an edge exists.
const GEDGraph & graph(GEDGraph::GraphID graph_id) const
Provides access to a graph.
void vectorize_edge_label(LabelID edge_label, std::vector< double > &vector_representation) const
Computes an edge label's representation as a real-valued vector.
double mean_node_ins_cost(const GEDGraph &graph) const
Returns the mean cost of inserting a node contained in a graph.
GEDGraph::NodeID pre_image(GEDGraph::NodeID node) const
Returns pre-image of a node.
double min_edit_cost(const GEDGraph &g, const GEDGraph &h) const
Returns the minimal edit cost between two graphs.
double mean_node_subs_cost(const GEDGraph &g, const GEDGraph &h) const
Returns the mean cost of substituting a node contained in a graph by a node contained in another grap...
Edit cost functions for chemical graphs such as the ones contained in the datasets Mutagenicity...
double min_node_del_cost(const GEDGraph &graph) const
Returns the minimal cost of deleting a node contained in a graph.
double min_edge_edit_cost(const GEDGraph &g, const GEDGraph &h) const
Returns the minimal edge edit cost between two graphs.
double min_edge_subs_cost(const GEDGraph &g, const GEDGraph &h) const
Returns the minimal cost of substituting a edge contained in a graph by a edge contained in another g...
std::size_t num_edge_labels() const
Returns the number of edge labels.
bool is_shuffled_graph_copy(GEDGraph::GraphID graph_id) const
Checks if a graph is a shuffled copy of another graph.
double max_node_del_cost(const GEDGraph &graph) const
Returns the maximal cost of deleting a node contained in a graph.
double induced_cost() const
Returns the induced cost.
std::size_t LabelID
Internally used type of node and edge labels.
double mean_edge_del_cost(const GEDGraph &graph) const
Returns the mean cost of deleting a edge contained in a graph.
double max_edit_cost(const GEDGraph &g, const GEDGraph &h) const
Returns the maximal edit cost between two graphs.
NodeID tail(EdgeID edge) const
Returns the tail of an edge.
LabelID get_node_label(NodeID node) const
Returns the label of a given node.
std::size_t num_edges() const
Returns the number of edges.
std::vector< GEDGraph >::const_iterator end() const
Provides access to the graphs contained in the instance.
static NodeID dummy_node()
Returns a dummy node.
double max_node_edit_cost() const
Returns the maximal node edit cost between any two graphs contained in the instance.
bool shuffled_graph_copies_available() const
Checks if shuffled graph copies are available.
LabelID get_edge_label(EdgeID edge) const
Returns the label of a given edge.
GEDGraph::GraphID id_shuffled_graph_copy(GEDGraph::GraphID graph_id) const
Returns ID of a graph's shuffled copy.
double mean_edge_ins_cost(const GEDGraph &graph) const
Returns the mean cost of inserting a edge contained in a graph.
double swap_cost(const GEDGraph &g, const GEDGraph &h, const NodeMap::Assignment &assignment_1, const NodeMap::Assignment &assignment_2, NodeMap &node_map) const
Computes the cost of swapping two assignments in a node map while leaving the node map unchanged...
void vectorize_node_label(LabelID node_label, std::vector< double > &vector_representation) const
Computes a node label's representation as a real-valued vector.
std::pair< incident_edge_iterator, incident_edge_iterator > incident_edges(NodeID node) const
Provides access to all incident edges of a node.
std::size_t num_graphs_without_shuffled_copies() const
Returns the number of graphs in the instance without the shuffled copies.
double max_edge_ins_cost(const GEDGraph &graph) const
Returns the maximal cost of inserting a edge contained in a graph.
double min_edge_del_cost(const GEDGraph &graph) const
Returns the minimal cost of deleting a edge contained in a graph.
Edit costs for graphs contain in CMU dataset.
double mean_edge_subs_cost(const GEDGraph &g, const GEDGraph &h) const
Returns the mean cost of substituting a edge contained in a graph by a edge contained in another grap...
std::vector< GEDGraph >::const_iterator begin() const
Provides access to the graphs contained in the instance.
double max_node_subs_cost(const GEDGraph &g, const GEDGraph &h) const
Returns the maximal cost of substituting a node contained in a graph by a node contained in another g...
Edit costs for graphs contained in Letter datasets.
double min_edge_ins_cost(const GEDGraph &graph) const
Returns the minimal cost of inserting a edge contained in a graph.
std::pair< node_iterator, node_iterator > nodes() const
Provides access to all nodes in the graph.
double max_edge_del_cost(const GEDGraph &graph) const
Returns the maximal cost of deleting a edge contained in a graph.
The normalized input graphs used by GEDLIB. All labels are integers.
double max_edge_edit_cost() const
Returns the maximal edge edit cost between any two graphs contained in the instance.
void add_assignment(GEDGraph::NodeID i, GEDGraph::NodeID k)
Add node substitution, insertion, or deletion to the node map.
void set_induced_cost(double induced_cost)
Sets the induced cost of the node map.
constexpr LabelID dummy_label()
Returns a dummy label.
bool quasimetric_costs() const
Checks if the edit costs are quasimetric.
double max_edge_subs_cost(const GEDGraph &g, const GEDGraph &h) const
Returns the maximal cost of substituting a edge contained in a graph by a edge contained in another g...
double min_node_edit_cost(const GEDGraph &g, const GEDGraph &h) const
Returns the minimal node edit cost between two graphs.
Global namespace for GEDLIB.
Eager initialization, no shuffled graph copies are constructed.
EditCosts
Selects the edit costs.
void save_node_map(const std::string &filename, GEDGraph::NodeID g_id, GEDGraph::NodeID h_id, const NodeMap &node_map, bool append=true) const
Saves a node map.
std::size_t num_node_labels() const
Returns the number of node labels.
GEDGraph::NodeID image(GEDGraph::NodeID node) const
Returns image of a node.
Implements constant edit cost functions.
double mean_node_del_cost(const GEDGraph &graph) const
Returns the mean cost of deleting a node contained in a graph.
Edit costs for graphs contained in Fingerprint dataset.
double min_node_ins_cost(const GEDGraph &graph) const
Returns the minimal cost of inserting a node contained in a graph.
Edit cost functions for the dataset GREC.
std::size_t NodeID
Internally used vertex ID type.
Abstract class for defining edit cost functions.
Eager initialization, shuffled graph copies are constructed.
Edit costs for graphs contained in Protein dataset.
void load_node_map(const std::string &filename, GEDGraph::NodeID g_id, GEDGraph::NodeID h_id, NodeMap &node_map) const
Loads a node map from a file.
std::pair< edge_iterator, edge_iterator > edges() const
Provides access to all edge in the graph.
std::size_t num_rows() const
Returns the number of rows.
std::size_t num_graphs() const
Returns the number of graphs.