TTK
Loading...
Searching...
No Matches
Propagation.h
Go to the documentation of this file.
1#pragma once
2
3#include <boost/heap/fibonacci_heap.hpp>
4#include <vector>
5
6namespace ttk {
7 namespace lts {
8
10 template <typename IT>
11 struct Propagation {
12
13 // union find parent (path compressed)
15
16 // direct parent propagation
18
19 // propagation data
20 std::vector<IT> criticalPoints;
21 boost::heap::fibonacci_heap<std::pair<IT, IT>> queue;
23 std::vector<IT> segment;
24 bool aborted{false};
25
26 mutable IT nIterations{0};
27
28 // find parent with path compression
29 inline Propagation *find() {
30 if(this->ufParent == this)
31 return this;
32 else {
33 auto tmp = this->ufParent->find();
34#ifdef TTK_ENABLE_OPENMP
35#pragma omp atomic write
36#endif // TTK_ENABLE_OPENMP
37 this->ufParent = tmp;
38 return this->ufParent;
39 }
40 }
41
42 static inline int unify(Propagation<IT> *p0, Propagation<IT> *p1) {
43 if(p1 == nullptr)
44 return 1;
45
46 p0 = p0->find();
47 p1 = p1->find();
48
49 if(p0 == p1)
50 return 1;
51
52 // store parent without path compression
53 p1->parent = p0;
54
55 // update union find tree
56 p1->ufParent = p0;
57
58 p0->segmentSize += p1->segmentSize;
59
60 // merge f. heaps
61 p0->queue.merge(p1->queue);
62
63 return 1;
64 }
65 };
66 } // namespace lts
67} // namespace ttk
The Topology ToolKit.
Superlevel Set Component Propagation.
Definition Propagation.h:11
std::vector< IT > criticalPoints
Definition Propagation.h:20
Propagation< IT > * parent
Definition Propagation.h:17
boost::heap::fibonacci_heap< std::pair< IT, IT > > queue
Definition Propagation.h:21
Propagation< IT > * ufParent
Definition Propagation.h:14
std::vector< IT > segment
Definition Propagation.h:23
Propagation * find()
Definition Propagation.h:29
static int unify(Propagation< IT > *p0, Propagation< IT > *p1)
Definition Propagation.h:42