Skip to content

Commit 0a3c6b7

Browse files
committed
Add same root assertion for link and lowest_common_ancestor; Move typename outside of template
1 parent e38cfc8 commit 0a3c6b7

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

include/boost/graph/link_cut_trees.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,9 @@ namespace boost
3838
}
3939

4040
template <class Element>
41-
inline void link(Element x, Element y) // Element x must be a tree root
41+
inline void link(Element x, Element y)
4242
{
43+
BOOST_ASSERT(find_root(x) == x); // Element x must be a tree root
4344
Element r = expose(x);
4445
r = join(r, r, expose(y));
4546
put_successor(r, r);
@@ -55,8 +56,9 @@ namespace boost
5556
}
5657

5758
template <class Element>
58-
inline Element lowest_common_ancestor(Element x, Element y) // Elements x and y must have same root
59+
inline Element lowest_common_ancestor(Element x, Element y)
5960
{
61+
BOOST_ASSERT(find_root(x) == find_root(y)); // Elements x and y must have same root
6062
expose(x);
6163
return expose(y);
6264
}

test/link_cut_trees_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ BOOST_AUTO_TEST_CASE(link_cut_trees_test6)
194194
{
195195
typedef associative_property_map< std::map<std::string, int> > id_map_t;
196196
typedef vector_property_map<std::string> inverse_id_map_t;
197-
typedef link_cut_trees_with_storage<id_map_t, inverse_id_map_t, typename std::map<int, int> > link_cut_trees_t;
197+
typedef std::map<int, int> index_map_container_t;
198+
typedef link_cut_trees_with_storage<id_map_t, inverse_id_map_t, index_map_container_t> link_cut_trees_t;
198199
std::vector<std::string> elements;
199200
std::vector<int> numbers(100);
200201
std::map<std::string, int> id_map;

0 commit comments

Comments
 (0)