Skip to content

Commit

Permalink
Add same root assertion for link and lowest_common_ancestor; Move…
Browse files Browse the repository at this point in the history
… typename outside of template
  • Loading branch information
yi-ji committed Jun 23, 2020
1 parent e38cfc8 commit 0a3c6b7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
6 changes: 4 additions & 2 deletions include/boost/graph/link_cut_trees.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ namespace boost
}

template <class Element>
inline void link(Element x, Element y) // Element x must be a tree root
inline void link(Element x, Element y)
{
BOOST_ASSERT(find_root(x) == x); // Element x must be a tree root
Element r = expose(x);
r = join(r, r, expose(y));
put_successor(r, r);
Expand All @@ -55,8 +56,9 @@ namespace boost
}

template <class Element>
inline Element lowest_common_ancestor(Element x, Element y) // Elements x and y must have same root
inline Element lowest_common_ancestor(Element x, Element y)
{
BOOST_ASSERT(find_root(x) == find_root(y)); // Elements x and y must have same root
expose(x);
return expose(y);
}
Expand Down
3 changes: 2 additions & 1 deletion test/link_cut_trees_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,8 @@ BOOST_AUTO_TEST_CASE(link_cut_trees_test6)
{
typedef associative_property_map< std::map<std::string, int> > id_map_t;
typedef vector_property_map<std::string> inverse_id_map_t;
typedef link_cut_trees_with_storage<id_map_t, inverse_id_map_t, typename std::map<int, int> > link_cut_trees_t;
typedef std::map<int, int> index_map_container_t;
typedef link_cut_trees_with_storage<id_map_t, inverse_id_map_t, index_map_container_t> link_cut_trees_t;
std::vector<std::string> elements;
std::vector<int> numbers(100);
std::map<std::string, int> id_map;
Expand Down

0 comments on commit 0a3c6b7

Please sign in to comment.