ensure all outer vertices are scanned
This commit is contained in:
parent
14474189c4
commit
1b9f930adf
1 changed files with 89 additions and 77 deletions
|
@ -30,11 +30,23 @@ std::vector<NodeId> path_to_forest_root(Graph const & graph, NodeId id)
|
||||||
return retval;
|
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 maximum_matching_from_initial_matching(Graph & graph)
|
||||||
{
|
{
|
||||||
graph.reset_forest();
|
graph.reset_forest();
|
||||||
for(NodeId id = 0; id < graph.num_nodes(); ++id) {
|
NodeId id;
|
||||||
if (graph.is_outer(id))
|
while((id = find_outer_vertex(graph)) != invalid_node_id)
|
||||||
{
|
{
|
||||||
for(NodeId neighbor_id : graph.node(id).neighbors())
|
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;
|
return graph;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue