27 std::vector<AtomicUF> nodesUF_;
31 std::vector<idNode> customTreeLeaves;
32 bool useCustomTree =
false;
39 template <
typename scalarType>
41 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs,
50 template <
typename scalarType>
53 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs);
55 template <
typename scalarType>
58 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs);
63 nodesUF_[parentNode].find()->addArcToClose(toAdd);
67 return nodesUF_[current].find()->getOpenedArcs().size();
70 template <
typename scalarType>
74 scalarType minVal = tree->
getValue<scalarType>(minVert);
77 for(
const auto nodeid : uf->getOpenedArcs()) {
78 const SimplexId vtmp = nodesUF_[nodeid].find()->getExtrema();
79 const scalarType tmpVal = tree->
getValue<scalarType>(vtmp);
81 and ((!isJt and tmpVal > minVal) or (isJt and tmpVal < minVal)))
82 or (not useCustomTree and tree->
compLower(vtmp, minVert))) {
92 nodesUF_[current].find()->clearOpenedArcs();
95 template <
typename scalarType>
98 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs,
103 const scalarType curVal = (not useCustomTree)
105 : tree->
getValue<scalarType>(curVert);
108 const SimplexId tmpVert = nodesUF_[nodeid].find()->getExtrema();
111 const scalarType tmpVal = (not useCustomTree)
113 : tree->
getValue<scalarType>(tmpVert);
114 if((useCustomTree and tmpVal < curVal)
115 or (not useCustomTree and
scalars_->isLower(tmpVert, curVert))) {
116 pairs.emplace_back(tmpVert, curVert, curVal - tmpVal);
118 pairs.emplace_back(tmpVert, curVert, tmpVal - curVal);
127template <
typename scalarType>
129 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs,
137 nbLeaves = customTreeLeaves.size();
145 pairs.reserve(nbLeaves);
148 nodesUF_.resize(nbNodes);
150 for(
idNode nid = 0; nid < nbNodes; ++nid) {
158template <
typename scalarType>
161 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs) {
162 auto getParentNode = [&](
const idNode current) {
167 ::std::queue<idNode> toSee;
170 auto &vectLeaves = (not useCustomTree) ? tree->
getLeaves() : customTreeLeaves;
171 for(
auto nid : vectLeaves) {
175 while(!toSee.empty()) {
176 const idNode current = toSee.front();
187 const idNode parentNode = getParentNode(current);
195 nodesUF_[parentNode].find()->setExtrema(mostPersist);
196 toSee.push(parentNode);
201template <
typename scalarType>
204 std::vector<std::tuple<SimplexId, SimplexId, scalarType>> &pairs) {
205 auto comp = [&](
const std::tuple<SimplexId, SimplexId, scalarType> a,
206 const std::tuple<SimplexId, SimplexId, scalarType> b) {
207 return std::get<2>(a) < std::get<2>(b);
210 sort(pairs.begin(), pairs.end(), comp);
#define ttkNotUsed(x)
Mark function/method parameters that are not used in the function body at all.
FTMAtomicVector< idSuperArc > & getOpenedArcs()
static AtomicUF * makeUnion(AtomicUF *uf0, AtomicUF *uf1)
void computePersistencePairs(std::vector< std::tuple< SimplexId, SimplexId, scalarType > > &pairs, const bool jt)
void clearPendingNodes(const idNode current)
void setCustomTree(ftm::FTMTree_MT *cTree)
void computePairs(ftm::FTMTree_MT *tree, std::vector< std::tuple< SimplexId, SimplexId, scalarType > > &pairs)
idNode countPendingNode(const idNode current)
void sortPairs(ftm::FTMTree_MT *tree, std::vector< std::tuple< SimplexId, SimplexId, scalarType > > &pairs)
void createPairs(const idNode current, std::vector< std::tuple< SimplexId, SimplexId, scalarType > > &pairs, ftm::FTMTree_MT *tree, const SimplexId mp)
SimplexId getMostPersistVert(const idNode current, ftm::FTMTree_MT *tree)
void addPendingNode(const idNode parentNode, const idNode toAdd)
FTMTree_MT * getSplitTree()
FTMTree_MT * getJoinTree()
Node * getNode(idNode nodeId) const
const scalarType & getValue(SimplexId nodeId) const
SuperArc * getSuperArc(idSuperArc i)
idNode getNumberOfNodes() const
idNode getNumberOfLeaves() const
void getLeavesFromTree(std::vector< idNode > &res) const
const std::vector< idNode > & getLeaves() const
std::shared_ptr< Scalars > scalars_
bool compLower(const SimplexId a, const SimplexId b)
idSuperArc getUpSuperArcId(idSuperArc neighborId) const
idSuperArc getNumberOfDownSuperArcs() const
SimplexId getVertexId() const
idSuperArc getNumberOfUpSuperArcs() const
idNode getUpNodeId() const
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
unsigned int idNode
Node index in vect_nodes_.
TTK base package defining the standard types.
int SimplexId
Identifier type for simplices of any dimension.