fix: output matching, not whole graph
This commit is contained in:
parent
354d96774d
commit
eb1e7e8dc8
1 changed files with 13 additions and 4 deletions
|
@ -43,7 +43,7 @@ NodeId find_outer_vertex(Graph const & graph)
|
|||
return invalid_node_id;
|
||||
}
|
||||
|
||||
Graph maximum_matching_from_initial_matching(Graph & graph)
|
||||
void maximum_matching_from_initial_matching(Graph & graph)
|
||||
{
|
||||
graph.reset_forest();
|
||||
NodeId id;
|
||||
|
@ -81,7 +81,7 @@ Graph maximum_matching_from_initial_matching(Graph & graph)
|
|||
}
|
||||
// Note that since this is tail-recursion, this will not generate
|
||||
// new stack frames in OPT mode
|
||||
return maximum_matching(graph);
|
||||
maximum_matching(graph);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -139,7 +139,6 @@ Graph maximum_matching_from_initial_matching(Graph & graph)
|
|||
}
|
||||
graph.node(id).scanned = true;
|
||||
}
|
||||
return graph;
|
||||
};
|
||||
|
||||
void find_greedy_matching(Graph & graph)
|
||||
|
@ -162,7 +161,17 @@ void find_greedy_matching(Graph & graph)
|
|||
|
||||
Graph maximum_matching(Graph & graph) {
|
||||
find_greedy_matching(graph);
|
||||
return maximum_matching_from_initial_matching(graph);
|
||||
maximum_matching_from_initial_matching(graph);
|
||||
|
||||
ED::Graph matching = ED::Graph(graph.num_nodes());
|
||||
for (NodeId id = 0; id < graph.num_nodes(); ++id)
|
||||
{
|
||||
if (graph.matched_neighbor(id) > id)
|
||||
{
|
||||
matching.add_edge(id, graph.matched_neighbor(id));
|
||||
}
|
||||
}
|
||||
return matching;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue