1
#ifndef BOOST_DETAIL_DISJOINT_SETS_HPP
2
#define BOOST_DETAIL_DISJOINT_SETS_HPP
8
template <class ParentPA, class Vertex>
10
find_representative_with_path_halving(ParentPA p, Vertex v)
12
Vertex parent = get(p, v);
13
Vertex grandparent = get(p, parent);
14
while (parent != grandparent) {
15
put(p, v, grandparent);
18
grandparent = get(p, parent);
23
template <class ParentPA, class Vertex>
25
find_representative_with_full_compression(ParentPA parent, Vertex v)
28
Vertex ancestor = get(parent, v);
29
while (ancestor != v) {
31
ancestor = get(parent, v);
34
while (ancestor != v) {
35
put(parent, old, ancestor);
42
/* the postcondition of link sets is:
43
component_representative(i) == component_representative(j)
45
template <class ParentPA, class RankPA, class Vertex,
46
class ComponentRepresentative>
48
link_sets(ParentPA p, RankPA rank, Vertex i, Vertex j,
49
ComponentRepresentative comp_rep)
54
if (get(rank, i) > get(rank, j))
58
if (get(rank, i) == get(rank, j))
63
// normalize components has the following postcondidition:
65
// that is, the representative is the node with the smallest index in its class
66
// as its precondition it it assumes that the node container is compressed
68
template <class ParentPA, class Vertex>
70
normalize_node(ParentPA p, Vertex i)
72
if (i > get(p,i) || get(p, get(p,i)) != get(p,i))
73
put(p,i, get(p, get(p,i)));
83
#endif // BOOST_DETAIL_DISJOINT_SETS_HPP