add greedy heuristic for initialization

This commit is contained in:
Maximilian Keßler 2023-11-05 19:43:29 +01:00
parent d5f01f5c70
commit 5674dff7a6
Signed by: max
GPG Key ID: BCC5A619923C0BA5
1 changed files with 5 additions and 3 deletions

View File

@ -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());