From 354d96774d657f6cd489cbc269e5a40f36e6ce08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sun, 5 Nov 2023 13:11:59 +0100 Subject: [PATCH] fix main: run on correct graphs --- src/edmonds.cpp | 1 + src/example.cpp | 20 ++------------------ 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/edmonds.cpp b/src/edmonds.cpp index a77f82b..8b81dbf 100644 --- a/src/edmonds.cpp +++ b/src/edmonds.cpp @@ -1,4 +1,5 @@ #include "edmonds.h" +#include using namespace ED; diff --git a/src/example.cpp b/src/example.cpp index 62a8292..d874ed9 100644 --- a/src/example.cpp +++ b/src/example.cpp @@ -16,26 +16,10 @@ int main(int argc, char** argv) if (not input_file_graph.is_open()) { throw std::runtime_error(std::string("Could not open file for reading: ") + argv[1]); } - ED::Graph const graph = ED::Graph::read_dimacs(input_file_graph); - - ED::Graph greedy_matching_as_graph{graph.num_nodes()}; - for (ED::NodeId node_id = 0; node_id < graph.num_nodes(); ++node_id) - { - if (greedy_matching_as_graph.node(node_id).neighbors().empty()) - { - for (ED::NodeId neighbor_id : graph.node(node_id).neighbors()) - { - if (greedy_matching_as_graph.node(neighbor_id).neighbors().empty()) - { - greedy_matching_as_graph.add_edge(node_id, neighbor_id); - break; // Do not add more edges incident to this node! - } - } - } - } + ED::Graph graph = ED::Graph::read_dimacs(input_file_graph); // Now, calculate the matching - ED::Graph optimum_matching = Edmonds::maximum_matching(greedy_matching_as_graph); + ED::Graph optimum_matching = Edmonds::maximum_matching(graph); std::cout << optimum_matching; return EXIT_SUCCESS; }