# HG changeset patch # User Balazs Dezso # Date 2008-12-21 20:45:25 # Node ID 81d40f1c850ce35cfe7dfeb1e811127195d064c3 # Parent 561be42c4b9935bf3e30a922b8945b2397286a8f Bug fix in heap unionfind (ticket #197) The previous bugfix set the minimum value in internal nodes wrongly. It corrects the problem. diff --git a/lemon/unionfind.h b/lemon/unionfind.h --- a/lemon/unionfind.h +++ b/lemon/unionfind.h @@ -1177,7 +1177,8 @@ int pd = nodes[jd].parent; if (nodes[nodes[jd].next].size < cmax) { pushLeft(nodes[jd].next, nodes[jd].left); - if (nodes[jd].item == nodes[pd].item) { + if (less(jd, nodes[jd].next) || + nodes[jd].item == nodes[pd].item) { nodes[nodes[jd].next].prio = nodes[jd].prio; nodes[nodes[jd].next].item = nodes[jd].item; } @@ -1220,7 +1221,8 @@ int pd = nodes[jd].parent; if (nodes[nodes[jd].prev].size < cmax) { pushRight(nodes[jd].prev, nodes[jd].right); - if (nodes[jd].item == nodes[pd].item) { + if (less(jd, nodes[jd].prev) || + nodes[jd].item == nodes[pd].item) { nodes[nodes[jd].prev].prio = nodes[jd].prio; nodes[nodes[jd].prev].item = nodes[jd].item; } @@ -1253,11 +1255,6 @@ return comp(nodes[id].prio, nodes[jd].prio); } - bool equal(int id, int jd) const { - return !less(id, jd) && !less(jd, id); - } - - public: /// \brief Returns true when the given class is alive.