diff --git a/lemon/unionfind.h b/lemon/unionfind.h --- a/lemon/unionfind.h +++ b/lemon/unionfind.h @@ -1288,6 +1288,15 @@ : index(_index), first_class(-1), first_free_class(-1), first_free_node(-1) {} + /// \brief Clears the union-find data structure + /// + /// Erase each item from the data structure. + void clear() { + nodes.clear(); + classes.clear(); + first_free_node = first_free_class = first_class = -1; + } + /// \brief Insert a new node into a new component. /// /// Insert a new node into a new component.