From 5674dff7a680194fd368d4df1e1682520da5ff53 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Ke=C3=9Fler?= Date: Sun, 5 Nov 2023 19:43:29 +0100 Subject: [PATCH] add greedy heuristic for initialization --- src/edmonds.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/edmonds.cpp b/src/edmonds.cpp index 2c0e869..cea9dd6 100644 --- a/src/edmonds.cpp +++ b/src/edmonds.cpp @@ -214,12 +214,13 @@ void find_greedy_matching(Graph & graph) for(NodeId node_id = 0; node_id < graph.num_nodes(); ++node_id) { if (graph.matched_neighbor(node_id) == node_id) { - for(NodeId neighbor_id : graph.node(node_id).neighbors()) + for(NodeId const neighbor_id : graph.node(node_id).neighbors()) { if(graph.matched_neighbor(neighbor_id) == neighbor_id) { graph.node(neighbor_id).matched_neighbor = node_id; graph.node(node_id).matched_neighbor = neighbor_id; + break; } } } @@ -227,8 +228,9 @@ void find_greedy_matching(Graph & graph) } Graph maximum_matching(Graph & graph) { - //find_greedy_matching(graph); - graph.reset_matching(); + graph.reset_forest(); + find_greedy_matching(graph); + check_integrity(graph); maximum_matching_from_initial_matching(graph); ED::Graph matching = ED::Graph(graph.num_nodes());