ensure all outer vertices are scanned

This commit is contained in:
Maximilian Keßler 2023-11-05 13:06:50 +01:00
parent 14474189c4
commit 1b9f930adf
Signed by: max
GPG key ID: BCC5A619923C0BA5

View file

@ -30,11 +30,23 @@ std::vector<NodeId> path_to_forest_root(Graph const & graph, NodeId id)
return retval;
}
NodeId find_outer_vertex(Graph const & graph)
{
for(NodeId id = 0; id < graph.num_nodes(); ++id)
{
if (not graph.node(id).scanned and graph.is_outer(id))
{
return id;
}
}
return invalid_node_id;
}
Graph maximum_matching_from_initial_matching(Graph & graph)
{
graph.reset_forest();
for(NodeId id = 0; id < graph.num_nodes(); ++id) {
if (graph.is_outer(id))
NodeId id;
while((id = find_outer_vertex(graph)) != invalid_node_id)
{
for(NodeId neighbor_id : graph.node(id).neighbors())
{
@ -124,7 +136,7 @@ Graph maximum_matching_from_initial_matching(Graph & graph)
}
}
}
}
graph.node(id).scanned = true;
}
return graph;
};