Commit b8d43e2b authored by Edwin Carlinet's avatar Edwin Carlinet
Browse files

Add the checktree routines for Morphological Tree Sanity Check.

    *  mln/morpho/datastruct/checktree.hpp: New.
parent f7f14d76
#ifndef MLN_MORPHO_DATASTRUCT_CHECKTREE_HPP
# define MLN_MORPHO_DATASTRUCT_CHECKTREE_HPP
# include <mln/morpho/datastruct/component_tree.hpp>
namespace mln
{
namespace morpho
{
namespace internal
{
template <class Tree>
void
checktree(const Tree& tree)
{
typename Tree::node_type prec = tree.nend();
mln_foreach(auto node, tree.nodes())
{
mln_assertion(node.get_parent_id() == prec.id() or
prec.get_next_sibling_id() == node.id());
mln_assertion(node.next_node().get_parent_id() == node.id() or
node.get_next_node_id() == node.get_next_sibling_id());
mln_assertion(node.next_sibling().get_parent_id() == node.get_parent_id() or
node.get_next_sibling_id() == node.parent().get_next_sibling_id());
prec = node;
}
}
}
}
}
#endif // ! MLN_MORPHO_DATASTRUCT_CHECKTREE_HPP
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment