more checks
This commit is contained in:
parent
c972fc309c
commit
7c36caa505
1 changed files with 34 additions and 0 deletions
|
@ -9,12 +9,46 @@ void check_integrity(Graph const & graph)
|
||||||
{
|
{
|
||||||
for(NodeId id = 0; id < graph.num_nodes(); ++id)
|
for(NodeId id = 0; id < graph.num_nodes(); ++id)
|
||||||
{
|
{
|
||||||
|
// Check that μ encodes a valid matching
|
||||||
NodeId matched = graph.matched_neighbor(id);
|
NodeId matched = graph.matched_neighbor(id);
|
||||||
if(matched != id)
|
if(matched != id)
|
||||||
{
|
{
|
||||||
assert(graph.matched_neighbor(matched) == id);
|
assert(graph.matched_neighbor(matched) == id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (graph.is_out_of_forest(id))
|
||||||
|
{
|
||||||
|
assert(graph.phi(id) == id);
|
||||||
|
assert(graph.rho(id) == id);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// check for a path to the root, i.e. ρ(node)
|
||||||
|
NodeId cur_node = id;
|
||||||
|
while(cur_node != graph.rho(cur_node))
|
||||||
|
{
|
||||||
|
// If the condition was true, then cur_node is outer, part of a blossom
|
||||||
|
// and we want to follow its path
|
||||||
|
// therefore, we check that both φ and μ are not the identity on this node
|
||||||
|
// and point to vertices that have the same rho
|
||||||
|
assert(graph.matched_neighbor(cur_node) != cur_node);
|
||||||
|
assert(graph.phi(cur_node) != cur_node);
|
||||||
|
assert(graph.rho(graph.matched_neighbor(cur_node)) == graph.rho(cur_node));
|
||||||
|
assert(graph.rho(graph.phi(cur_node)) == graph.rho(cur_node));
|
||||||
|
|
||||||
|
// now, walk along the matched edge
|
||||||
|
cur_node = graph.matched_neighbor(cur_node);
|
||||||
|
|
||||||
|
// now we want to walk along φ, this will again
|
||||||
|
// - not be the identity
|
||||||
|
// - result in a node that has the same rho
|
||||||
|
assert(graph.phi(cur_node) != cur_node);
|
||||||
|
assert(graph.rho(graph.phi(cur_node)) == graph.rho(cur_node));
|
||||||
|
|
||||||
|
cur_node = graph.matched_neighbor(graph.phi(cur_node));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (not graph.is_outer(id))
|
if (not graph.is_outer(id))
|
||||||
{
|
{
|
||||||
assert(graph.rho(id) == id);
|
assert(graph.rho(id) == id);
|
||||||
|
|
Loading…
Reference in a new issue