TTK
Loading...
Searching...
No Matches
MergeTreeAxesAlgorithmBase.h
Go to the documentation of this file.
1
10
11#pragma once
12
13#include <Geometry.h>
14#include <MergeTreeBarycenter.h>
15#include <MergeTreeBase.h>
16#include <MergeTreeDistance.h>
17#include <MergeTreeUtils.h>
18#include <Statistics.h>
19
20#define ENERGY_COMPARISON_TOLERANCE 1e-6
21
22namespace ttk {
23
24 class MergeTreeAxesAlgorithmBase : virtual public Debug,
25 public MergeTreeBase {
26
27 protected:
28 bool deterministic_ = true;
29 unsigned int numberOfGeodesics_ = 1;
30 unsigned int k_ = 10;
32
33 // Clean correspondence
34 std::vector<std::vector<int>> trees2NodeCorr_;
35
36 public:
39 "MergeTreeAxesAlgorithmBase"); // inherited from Debug: prefix will
40 // be printed at the beginning of
41 // every msg
42 }
43
44 //----------------------------------------------------------------------------
45 // Matching / Distance
46 //----------------------------------------------------------------------------
47 template <class dataType>
51 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> &matching,
52 dataType &distance,
53 bool isCalled = false,
54 bool useDoubleInput = false,
55 bool isFirstInput = true) {
56 MergeTreeDistance mergeTreeDistance;
57 mergeTreeDistance.setDebugLevel(std::min(debugLevel_, 2));
58 mergeTreeDistance.setPreprocess(false);
59 mergeTreeDistance.setPostprocess(false);
60 mergeTreeDistance.setBranchDecomposition(true);
62 mergeTreeDistance.setKeepSubtree(false);
64 mergeTreeDistance.setIsCalled(isCalled);
65 mergeTreeDistance.setThreadNumber(this->threadNumber_);
66 mergeTreeDistance.setDistanceSquaredRoot(true); // squared root
67 mergeTreeDistance.setNodePerTask(nodePerTask_);
68 if(useDoubleInput) {
69 double weight = mixDistancesMinMaxPairWeight(isFirstInput);
70 mergeTreeDistance.setMinMaxPairWeight(weight);
71 }
72 distance = mergeTreeDistance.computeDistance<dataType>(
73 &(tree1.tree), &(tree2.tree), matching);
74 }
75
76 template <class dataType>
79 dataType &distance,
80 bool isCalled = false,
81 bool useDoubleInput = false,
82 bool isFirstInput = true) {
83 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> matching;
84 computeOneDistance<dataType>(tree1, tree2, matching, distance, isCalled,
85 useDoubleInput, isFirstInput);
86 }
87
88 //----------------------------------------------------------------------------
89 // Init
90 //----------------------------------------------------------------------------
91 template <class dataType>
93 ftm::MergeTree<dataType> &barycenter,
95 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> &matching,
96 std::vector<std::vector<double>> &v) {
97 ftm::FTMTree_MT *barycenterTree = &(barycenter.tree);
98 ftm::FTMTree_MT *treeTree = &(tree.tree);
99
100 std::vector<ftm::idNode> matchingVector;
101 getMatchingVector<dataType>(barycenter, tree, matching, matchingVector);
102
103 v.resize(barycenter.tree.getNumberOfNodes(), std::vector<double>(2, 0));
104 for(unsigned int j = 0; j < barycenter.tree.getNumberOfNodes(); ++j) {
105 if(barycenter.tree.isNodeAlone(j))
106 continue;
107 auto birthDeathBary
108 = getParametrizedBirthDeath<dataType>(barycenterTree, j);
109 std::tuple<dataType, dataType> birthDeath;
110 if(matchingVector[j] != std::numeric_limits<ftm::idNode>::max()) {
111 birthDeath
112 = getParametrizedBirthDeath<dataType>(treeTree, matchingVector[j]);
113 } else {
114 dataType projec
115 = (std::get<0>(birthDeathBary) + std::get<1>(birthDeathBary)) / 2.0;
116 birthDeath = std::make_tuple(projec, projec);
117 }
118 v[j][0] = std::get<0>(birthDeath) - std::get<0>(birthDeathBary);
119 v[j][1] = std::get<1>(birthDeath) - std::get<1>(birthDeathBary);
120 }
121 }
122
123 template <class dataType>
125 std::vector<std::vector<double>> &v,
126 std::vector<std::vector<std::vector<double>>> &vS,
127 std::vector<std::vector<std::vector<double>>> &v2s) {
128 // Get average norm of the previous vectors
129 std::vector<std::vector<double>> sumVs;
131 double newNorm = 0;
132 for(auto &sumVi : sumVs)
133 newNorm += ttk::Geometry::magnitude(sumVi) / sumVs.size();
134
135 // Generate random vector
136 v.resize(barycenter.tree.getNumberOfNodes(), std::vector<double>(2, 0));
137 for(unsigned int i = 0; i < barycenter.tree.getNumberOfNodes(); ++i) {
138 if(barycenter.tree.isNodeAlone(i))
139 continue;
140 v[i][0] = (double)rand() / RAND_MAX * newNorm * 2 - newNorm;
141 v[i][1] = (double)rand() / RAND_MAX * newNorm * 2 - newNorm;
142 }
143
144 // Change the norm of the random vector to be the average norm
145 double normV = ttk::Geometry::magnitudeFlatten(v);
146 for(unsigned int i = 0; i < barycenter.tree.getNumberOfNodes(); ++i) {
147 if(barycenter.tree.isNodeAlone(i))
148 continue;
149 v[i][0] = v[i][0] / normV * newNorm;
150 v[i][1] = v[i][1] / normV * newNorm;
151 }
152 }
153
154 template <class dataType, typename F>
156 int geodesicNumber,
157 ftm::MergeTree<dataType> &barycenter,
158 std::vector<ftm::MergeTree<dataType>> &trees,
159 ftm::MergeTree<dataType> &barycenter2,
160 std::vector<ftm::MergeTree<dataType>> &trees2,
161 std::vector<std::vector<double>> &v1,
162 std::vector<std::vector<double>> &v2,
163 std::vector<std::vector<double>> &trees2V1,
164 std::vector<std::vector<double>> &trees2V2,
165 int newVectorOffset,
166 std::vector<double> &inputToOriginDistances,
167 std::vector<std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>>
168 &baryMatchings,
169 std::vector<std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>>
170 &baryMatchings2,
171 std::vector<std::vector<double>> &inputToGeodesicsDistances,
172 std::vector<std::vector<std::vector<double>>> &vS,
173 std::vector<std::vector<std::vector<double>>> &v2s,
174 std::vector<std::vector<std::vector<double>>> &trees2Vs,
175 std::vector<std::vector<std::vector<double>>> &trees2V2s,
176 bool projectInitializedVectors,
177 F initializedVectorsProjection) {
178
179 bool doOffset = (newVectorOffset != 0);
180 // Get best distance, best matching and best index
181 dataType bestDistance = std::numeric_limits<dataType>::lowest();
182 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> bestMatching,
183 bestMatching2;
184 std::vector<std::tuple<double, unsigned int>> distancesAndIndexes(
185 trees.size());
186 int bestIndex = -1;
187 for(unsigned int i = 0; i < trees.size(); ++i) {
188 dataType distance = 0.0, distance2 = 0.0;
189 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> matching,
190 matching2;
191 if(geodesicNumber == 0) {
192 if(inputToOriginDistances.size() == 0) {
193 computeOneDistance<dataType>(
194 barycenter, trees[i], matching, distance, false, useDoubleInput_);
195 if(trees2.size() != 0) {
196 computeOneDistance<dataType>(barycenter2, trees2[i], matching2,
197 distance2, false, useDoubleInput_,
198 false);
199 distance = mixDistances(distance, distance2);
200 }
201 } else {
202 distance = inputToOriginDistances[i];
203 matching = baryMatchings[i];
204 if(trees2.size() != 0)
205 matching2 = baryMatchings2[i];
206 }
207 } else {
208 for(unsigned j = 0; j < inputToGeodesicsDistances.size(); ++j)
209 distance += inputToGeodesicsDistances[j][i];
210 distancesAndIndexes[i] = std::make_tuple(distance, i);
211 }
212 if(distance > bestDistance) {
213 bestDistance = distance;
214 bestMatching = matching;
215 bestMatching2 = matching2;
216 bestIndex = i;
217 }
218 }
219
220 // Sort all distances and their respective indexes
221 if(geodesicNumber != 0)
222 std::sort(distancesAndIndexes.begin(), distancesAndIndexes.end(),
223 [](const std::tuple<double, unsigned int> &a,
224 const std::tuple<double, unsigned int> &b) -> bool {
225 return (std::get<0>(a) > std::get<0>(b));
226 });
227
228 // Init vectors according farthest input
229 // (repeat with the ith farthest until projection gives non null vector)
230 unsigned int i = 0;
231 bool foundGoodIndex = false;
232 while(not foundGoodIndex) {
233 // Get matching of the ith farthest input
234 if(bestIndex >= 0 and bestIndex < (int)trees.size()) {
235 if(geodesicNumber != 0) {
236 if(baryMatchings.size() == 0
237 and (baryMatchings.size() == 0 or trees2.size() == 0)) {
238 dataType distance;
239 computeOneDistance<dataType>(barycenter, trees[bestIndex],
240 bestMatching, distance, false,
242 if(trees2.size() != 0)
243 computeOneDistance<dataType>(barycenter2, trees2[bestIndex],
244 bestMatching2, distance, false,
245 useDoubleInput_, false);
246 } else {
247 bestMatching = baryMatchings[bestIndex];
248 if(trees2.size() != 0)
249 bestMatching2 = baryMatchings2[bestIndex];
250 }
251 }
252
253 // Init vectors from matching
254 initVectorFromMatching<dataType>(
255 barycenter, trees[bestIndex], bestMatching, v1);
256 v2 = v1;
257 if(trees2.size() != 0) {
258 initVectorFromMatching<dataType>(
259 barycenter2, trees2[bestIndex], bestMatching2, trees2V1);
260 trees2V2 = trees2V1;
261 }
262 } else {
263 initRandomVector(barycenter, v1, vS, v2s);
264 v2 = v1;
265 if(trees2.size() != 0) {
266 initRandomVector(barycenter2, trees2V1, trees2Vs, trees2V2s);
267 trees2V2 = trees2V1;
268 }
269 }
270
271 // Project initialized vectors to satisfy constraints
272 if(projectInitializedVectors) {
273 initializedVectorsProjection(
274 geodesicNumber, barycenter, v1, v2, vS, v2s, barycenter2, trees2V1,
275 trees2V2, trees2Vs, trees2V2s, (trees2.size() != 0), 1);
276 }
277
278 // Check if the initialized vectors are good
279 foundGoodIndex
280 = (geodesicNumber == 0 or not ttk::Geometry::isVectorNullFlatten(v1));
281
282 // Init next bestIndex
283 if(not foundGoodIndex) {
284 i += 1;
285 if(i < distancesAndIndexes.size())
286 bestIndex = std::get<1>(distancesAndIndexes[i]);
287 else
288 bestIndex = -1;
289 }
290
291 // If newVector jump to the next valid bestIndex
292 if(foundGoodIndex and doOffset and bestIndex >= 0) {
293 bestIndex += newVectorOffset;
294 if(bestIndex >= (int)trees.size())
295 bestIndex = -1;
296 foundGoodIndex = false;
297 doOffset = false;
298 }
299 }
300 return bestIndex;
301 }
302
303 //----------------------------------------------------------------------------
304 // Barycenter
305 //----------------------------------------------------------------------------
306 template <class dataType>
308 std::vector<ftm::MergeTree<dataType>> &trees,
309 ftm::MergeTree<dataType> &baryMergeTree,
310 std::vector<std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>>
311 &matchings,
312 std::vector<double> &finalDistances,
313 double barycenterSizeLimitPercent,
314 unsigned int barycenterMaximumNumberOfPairs,
315 bool useDoubleInput = false,
316 bool isFirstInput = true) {
317 MergeTreeBarycenter mergeTreeBary;
318 mergeTreeBary.setDebugLevel(std::min(debugLevel_, 2));
319 mergeTreeBary.setPreprocess(false);
320 mergeTreeBary.setPostprocess(false);
321 mergeTreeBary.setBranchDecomposition(true);
323 mergeTreeBary.setKeepSubtree(false);
325 mergeTreeBary.setThreadNumber(this->threadNumber_);
326 mergeTreeBary.setDeterministic(deterministic_);
327 mergeTreeBary.setBarycenterSizeLimitPercent(barycenterSizeLimitPercent);
329 barycenterMaximumNumberOfPairs);
330
331 matchings.resize(trees.size());
332 mergeTreeBary.execute<dataType>(
333 trees, matchings, baryMergeTree, useDoubleInput, isFirstInput);
334 finalDistances = mergeTreeBary.getFinalDistances();
335 }
336
337 template <class dataType>
339 std::vector<ftm::MergeTree<dataType>> &trees,
340 ftm::MergeTree<dataType> &baryMergeTree,
341 std::vector<std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>>
342 &matchings,
343 std::vector<double> &finalDistances,
344 double barycenterSizeLimitPercent,
345 bool useDoubleInput = false,
346 bool isFirstInput = true) {
347 unsigned int barycenterMaximumNumberOfPairs = 0;
348 computeOneBarycenter(trees, baryMergeTree, matchings, finalDistances,
349 barycenterSizeLimitPercent,
350 barycenterMaximumNumberOfPairs, useDoubleInput,
351 isFirstInput);
352 }
353
354 template <class dataType>
356 std::vector<ftm::MergeTree<dataType>> &trees,
357 ftm::MergeTree<dataType> &baryMergeTree,
358 std::vector<std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>>
359 &matchings,
360 std::vector<double> &finalDistances,
361 bool useDoubleInput = false,
362 bool isFirstInput = true) {
363 computeOneBarycenter(trees, baryMergeTree, matchings, finalDistances,
364 barycenterSizeLimitPercent_, useDoubleInput,
365 isFirstInput);
366 }
367
368 template <class dataType>
370 std::vector<ftm::MergeTree<dataType>> &trees,
371 ftm::MergeTree<dataType> &baryMergeTree,
372 std::vector<std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>>
373 &matchings) {
374 std::vector<double> finalDistances;
375 computeOneBarycenter<dataType>(
376 trees, baryMergeTree, matchings, finalDistances);
377 }
378
379 template <class dataType>
381 ftm::MergeTree<dataType> &baryMergeTree) {
382 std::vector<std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>>
383 matchings;
384 computeOneBarycenter<dataType>(trees, baryMergeTree, matchings);
385 }
386
387 //----------------------------------------------------------------------------
388 // Preprocessing
389 //----------------------------------------------------------------------------
390 template <class dataType>
392 std::vector<std::vector<int>> &nodeCorr,
393 bool useMinMaxPairT = true) {
394 nodeCorr.resize(trees.size());
395#ifdef TTK_ENABLE_OPENMP
396#pragma omp parallel for schedule(dynamic) num_threads(this->threadNumber_)
397#endif
398 for(unsigned int i = 0; i < trees.size(); ++i) {
399 preprocessingPipeline<dataType>(
401 branchDecomposition_, useMinMaxPairT, cleanTree_, nodeCorr[i]);
402 if(trees.size() < 40)
403 printTreeStats(trees[i]);
404 }
405 if(trees.size() != 0)
406 printTreesStats(trees);
407 }
408
409 template <class dataType>
411 bool useMinMaxPairT = true) {
412 std::vector<std::vector<int>> nodeCorr(trees.size());
413 preprocessingTrees(trees, nodeCorr, useMinMaxPairT);
414 }
415
416 //----------------------------------------------------------------------------
417 // Utils
418 //----------------------------------------------------------------------------
419 // v[i] contains the node in tree matched to the node i in barycenter
420 template <class dataType>
422 ftm::MergeTree<dataType> &barycenter,
424 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> &matchings,
425 std::vector<ftm::idNode> &matchingVector) {
426 matchingVector.clear();
427 matchingVector.resize(barycenter.tree.getNumberOfNodes(),
428 std::numeric_limits<ftm::idNode>::max());
429 for(unsigned int j = 0; j < matchings.size(); ++j) {
430 auto match0 = std::get<0>(matchings[j]);
431 auto match1 = std::get<1>(matchings[j]);
432 if(match0 < barycenter.tree.getNumberOfNodes()
433 and match1 < tree.tree.getNumberOfNodes())
434 matchingVector[match0] = match1;
435 }
436 }
437
438 // v[i] contains the node in barycenter matched to the node i in tree
439 template <class dataType>
441 ftm::MergeTree<dataType> &barycenter,
443 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> &matchings,
444 std::vector<ftm::idNode> &matchingVector) {
445 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> invMatchings(
446 matchings.size());
447 for(unsigned int i = 0; i < matchings.size(); ++i)
448 invMatchings[i] = std::make_tuple(std::get<1>(matchings[i]),
449 std::get<0>(matchings[i]),
450 std::get<2>(matchings[i]));
451 getMatchingVector(tree, barycenter, invMatchings, matchingVector);
452 }
453
454 // m[i][j] contains the node in trees[j] matched to the node i in the
455 // barycenter
456 template <class dataType>
458 ftm::MergeTree<dataType> &barycenter,
459 std::vector<ftm::MergeTree<dataType>> &trees,
460 std::vector<std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>>
461 &matchings,
462 std::vector<std::vector<ftm::idNode>> &matchingMatrix) {
463 matchingMatrix.clear();
464 matchingMatrix.resize(
465 barycenter.tree.getNumberOfNodes(),
466 std::vector<ftm::idNode>(
467 trees.size(), std::numeric_limits<ftm::idNode>::max()));
468 for(unsigned int i = 0; i < trees.size(); ++i) {
469 std::vector<ftm::idNode> matchingVector;
470 getMatchingVector<dataType>(
471 barycenter, trees[i], matchings[i], matchingVector);
472 for(unsigned int j = 0; j < matchingVector.size(); ++j)
473 matchingMatrix[j][i] = matchingVector[j];
474 }
475 }
476
477 template <class dataType>
478 std::tuple<dataType, dataType>
480 return ttk::getParametrizedBirthDeath<dataType>(
481 tree, node, normalizedWasserstein_);
482 }
483
484 //----------------------------------------------------------------------------
485 // Utils
486 //----------------------------------------------------------------------------
487 template <class dataType>
489 ftm::MergeTree<dataType> &barycenter,
490 std::vector<ftm::MergeTree<dataType>> &trees,
491 std::vector<std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>>
492 &baryMatchings,
493 std::vector<std::vector<double>> &allTs,
494 std::vector<std::vector<double>> &branchesCorrelationMatrix,
495 std::vector<std::vector<double>> &persCorrelationMatrix) {
496 branchesCorrelationMatrix.resize(barycenter.tree.getNumberOfNodes(),
497 std::vector<double>(allTs.size(), 0.0));
498 persCorrelationMatrix = branchesCorrelationMatrix;
499
500 // m[i][j] contains the node in trees[j] matched to the node i in the
501 // barycenter
502 std::vector<std::vector<ftm::idNode>> matchingMatrix;
503 getMatchingMatrix(barycenter, trees, baryMatchings, matchingMatrix);
504
505 std::queue<ftm::idNode> queue;
506 queue.emplace(barycenter.tree.getRoot());
507 while(!queue.empty()) {
508 ftm::idNode node = queue.front();
509 queue.pop();
510
511 // Get births and deaths array
512 std::vector<double> births(trees.size(), 0.0),
513 deaths(trees.size(), 0.0), pers(trees.size(), 0.0);
514 for(unsigned int i = 0; i < trees.size(); ++i) {
515 auto matched = matchingMatrix[node][i];
516 std::tuple<dataType, dataType> birthDeath;
517 if(matched == std::numeric_limits<ftm::idNode>::max()) {
518 birthDeath = barycenter.tree.template getBirthDeath<dataType>(node);
519 auto projec
520 = (std::get<0>(birthDeath) + std::get<1>(birthDeath)) / 2.0;
521 birthDeath = std::make_tuple(projec, projec);
522 } else
523 birthDeath
524 = trees[i].tree.template getBirthDeath<dataType>(matched);
525 births[i] = std::get<0>(birthDeath);
526 deaths[i] = std::get<1>(birthDeath);
527 pers[i] = deaths[i] - births[i];
528 }
529
530 // Compute correlations
531 for(unsigned int g = 0; g < allTs.size(); ++g) {
532 double birthCorr = ttk::Statistics::corr(births, allTs[g]);
533 double deathCorr = ttk::Statistics::corr(deaths, allTs[g]);
534 double persCorr = ttk::Statistics::corr(pers, allTs[g]);
535
536 if(std::isnan(birthCorr))
537 birthCorr = 0.0;
538 if(std::isnan(deathCorr))
539 deathCorr = 0.0;
540 if(std::isnan(persCorr))
541 persCorr = 0.0;
542
543 auto birthDeathNode
544 = barycenter.tree.template getBirthDeathNode<dataType>(node);
545 auto birthNode = std::get<0>(birthDeathNode);
546 auto deathNode = std::get<1>(birthDeathNode);
547 branchesCorrelationMatrix[birthNode][g] = birthCorr;
548 branchesCorrelationMatrix[deathNode][g] = deathCorr;
549 persCorrelationMatrix[birthNode][g] = persCorr;
550 persCorrelationMatrix[deathNode][g] = persCorr;
551 }
552
553 // Push children to the queue
554 std::vector<ftm::idNode> children;
555 barycenter.tree.getChildren(node, children);
556 for(auto child : children)
557 queue.emplace(child);
558 }
559 }
560
561 //----------------------------------------------------------------------------
562 // Output Utils
563 //----------------------------------------------------------------------------
564 void zeroPadding(std::string &colName,
565 const size_t numberCols,
566 const size_t colIdx) {
567 std::string max{std::to_string(numberCols - 1)};
568 std::string cur{std::to_string(colIdx)};
569 std::string zer(max.size() - cur.size(), '0');
570 colName.append(zer).append(cur);
571 }
572
573 std::string getTableCoefficientName(int noGeodesics, int geodesicNum) {
574 std::string name{"T"};
575 zeroPadding(name, noGeodesics, geodesicNum);
576 return name;
577 }
578
579 std::string getTableCoefficientNormName(int noGeodesics, int geodesicNum) {
580 std::string name{"TNorm"};
581 zeroPadding(name, noGeodesics, geodesicNum);
582 return name;
583 }
584
585 std::string getTableVectorName(int noGeodesics,
586 int geodesicNum,
587 int vId,
588 int vComp,
589 bool isSecondInput = false) {
590 std::string indexString{};
591 zeroPadding(indexString, noGeodesics, geodesicNum);
592 std::string prefix{(isSecondInput ? "T2_" : "")};
593 std::string name{prefix + "V" + indexString + "_" + std::to_string(vId)
594 + "_" + std::to_string(vComp)};
595 return name;
596 }
597
598 std::string getTableCorrelationName(int noGeodesics, int geodesicNum) {
599 std::string name{"Corr"};
600 zeroPadding(name, noGeodesics, geodesicNum);
601 return name;
602 }
603
604 std::string getTableCorrelationPersName(int noGeodesics, int geodesicNum) {
605 std::string name{"CorrPers"};
606 zeroPadding(name, noGeodesics, geodesicNum);
607 return name;
608 }
609
610 std::string getTableCorrelationTreeName(int noTrees, int treeNum) {
611 std::string name{"Tree"};
612 zeroPadding(name, noTrees, treeNum);
613 return name;
614 }
615 }; // MergeTreeAxesAlgorithmBase class
616
617} // namespace ttk
int threadNumber_
Definition: BaseClass.h:95
virtual int setThreadNumber(const int threadNumber)
Definition: BaseClass.h:80
Minimalist debugging class.
Definition: Debug.h:88
int debugLevel_
Definition: Debug.h:379
void setDebugMsgPrefix(const std::string &prefix)
Definition: Debug.h:364
virtual int setDebugLevel(const int &debugLevel)
Definition: Debug.cpp:147
std::vector< std::vector< int > > trees2NodeCorr_
std::string getTableCorrelationTreeName(int noTrees, int treeNum)
void computeOneBarycenter(std::vector< ftm::MergeTree< dataType > > &trees, ftm::MergeTree< dataType > &baryMergeTree, std::vector< std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > > &matchings)
void computeOneBarycenter(std::vector< ftm::MergeTree< dataType > > &trees, ftm::MergeTree< dataType > &baryMergeTree, std::vector< std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > > &matchings, std::vector< double > &finalDistances, double barycenterSizeLimitPercent, unsigned int barycenterMaximumNumberOfPairs, bool useDoubleInput=false, bool isFirstInput=true)
std::tuple< dataType, dataType > getParametrizedBirthDeath(ftm::FTMTree_MT *tree, ftm::idNode node)
std::string getTableVectorName(int noGeodesics, int geodesicNum, int vId, int vComp, bool isSecondInput=false)
std::string getTableCorrelationPersName(int noGeodesics, int geodesicNum)
void computeOneDistance(ftm::MergeTree< dataType > &tree1, ftm::MergeTree< dataType > &tree2, std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > &matching, dataType &distance, bool isCalled=false, bool useDoubleInput=false, bool isFirstInput=true)
void computeOneBarycenter(std::vector< ftm::MergeTree< dataType > > &trees, ftm::MergeTree< dataType > &baryMergeTree, std::vector< std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > > &matchings, std::vector< double > &finalDistances, double barycenterSizeLimitPercent, bool useDoubleInput=false, bool isFirstInput=true)
void computeOneDistance(ftm::MergeTree< dataType > &tree1, ftm::MergeTree< dataType > &tree2, dataType &distance, bool isCalled=false, bool useDoubleInput=false, bool isFirstInput=true)
int initVectors(int geodesicNumber, ftm::MergeTree< dataType > &barycenter, std::vector< ftm::MergeTree< dataType > > &trees, ftm::MergeTree< dataType > &barycenter2, std::vector< ftm::MergeTree< dataType > > &trees2, std::vector< std::vector< double > > &v1, std::vector< std::vector< double > > &v2, std::vector< std::vector< double > > &trees2V1, std::vector< std::vector< double > > &trees2V2, int newVectorOffset, std::vector< double > &inputToOriginDistances, std::vector< std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > > &baryMatchings, std::vector< std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > > &baryMatchings2, std::vector< std::vector< double > > &inputToGeodesicsDistances, std::vector< std::vector< std::vector< double > > > &vS, std::vector< std::vector< std::vector< double > > > &v2s, std::vector< std::vector< std::vector< double > > > &trees2Vs, std::vector< std::vector< std::vector< double > > > &trees2V2s, bool projectInitializedVectors, F initializedVectorsProjection)
void zeroPadding(std::string &colName, const size_t numberCols, const size_t colIdx)
std::string getTableCoefficientNormName(int noGeodesics, int geodesicNum)
void computeOneBarycenter(std::vector< ftm::MergeTree< dataType > > &trees, ftm::MergeTree< dataType > &baryMergeTree, std::vector< std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > > &matchings, std::vector< double > &finalDistances, bool useDoubleInput=false, bool isFirstInput=true)
void computeOneBarycenter(std::vector< ftm::MergeTree< dataType > > &trees, ftm::MergeTree< dataType > &baryMergeTree)
void preprocessingTrees(std::vector< ftm::MergeTree< dataType > > &trees, std::vector< std::vector< int > > &nodeCorr, bool useMinMaxPairT=true)
void getInverseMatchingVector(ftm::MergeTree< dataType > &barycenter, ftm::MergeTree< dataType > &tree, std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > &matchings, std::vector< ftm::idNode > &matchingVector)
std::string getTableCorrelationName(int noGeodesics, int geodesicNum)
std::string getTableCoefficientName(int noGeodesics, int geodesicNum)
void getMatchingMatrix(ftm::MergeTree< dataType > &barycenter, std::vector< ftm::MergeTree< dataType > > &trees, std::vector< std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > > &matchings, std::vector< std::vector< ftm::idNode > > &matchingMatrix)
void initRandomVector(ftm::MergeTree< dataType > &barycenter, std::vector< std::vector< double > > &v, std::vector< std::vector< std::vector< double > > > &vS, std::vector< std::vector< std::vector< double > > > &v2s)
void computeBranchesCorrelationMatrix(ftm::MergeTree< dataType > &barycenter, std::vector< ftm::MergeTree< dataType > > &trees, std::vector< std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > > &baryMatchings, std::vector< std::vector< double > > &allTs, std::vector< std::vector< double > > &branchesCorrelationMatrix, std::vector< std::vector< double > > &persCorrelationMatrix)
void preprocessingTrees(std::vector< ftm::MergeTree< dataType > > &trees, bool useMinMaxPairT=true)
void getMatchingVector(ftm::MergeTree< dataType > &barycenter, ftm::MergeTree< dataType > &tree, std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > &matchings, std::vector< ftm::idNode > &matchingVector)
void initVectorFromMatching(ftm::MergeTree< dataType > &barycenter, ftm::MergeTree< dataType > &tree, std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > &matching, std::vector< std::vector< double > > &v)
void setPreprocess(bool preproc)
void setPostprocess(bool postproc)
void setDeterministic(bool deterministicT)
void setBarycenterMaximumNumberOfPairs(unsigned int maxi)
void setBarycenterSizeLimitPercent(double percent)
std::vector< double > getFinalDistances()
void execute(std::vector< ftm::MergeTree< dataType > > &trees, std::vector< double > &alphas, std::vector< std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > > &finalMatchings, ftm::MergeTree< dataType > &baryMergeTree, bool finalAsgnDoubleInput=false, bool finalAsgnFirstInput=true)
void setBranchDecomposition(bool useBD)
void setNormalizedWasserstein(bool normalizedWasserstein)
void setDistanceSquaredRoot(bool distanceSquaredRoot)
void setAssignmentSolver(int assignmentSolver)
Definition: MergeTreeBase.h:69
void setNodePerTask(int npt)
double mixDistances(dataType distance1, dataType distance2)
void printTreesStats(std::vector< ftm::FTMTree_MT * > &trees)
void setKeepSubtree(bool keepSubtree)
double mixDistancesMinMaxPairWeight(bool isFirstInput)
dataType computeDistance(ftm::FTMTree_MT *tree1, ftm::FTMTree_MT *tree2, std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > &outputMatching)
void setPreprocess(bool preproc)
void setPostprocess(bool postproc)
void setMinMaxPairWeight(double weight)
idNode getNumberOfNodes() const
Definition: FTMTree_MT.h:389
void getChildren(idNode nodeId, std::vector< idNode > &res)
bool isNodeAlone(idNode nodeId)
bool isVectorNullFlatten(const std::vector< std::vector< T > > &a)
Definition: Geometry.cpp:663
T magnitudeFlatten(const std::vector< std::vector< T > > &v)
Definition: Geometry.cpp:501
T magnitude(const T *v, const int &dimension=3)
Definition: Geometry.cpp:491
int multiAddVectorsFlatten(const std::vector< std::vector< std::vector< T > > > &a, const std::vector< std::vector< std::vector< T > > > &b, std::vector< std::vector< T > > &out)
Definition: Geometry.cpp:563
T corr(const T *v1, const T *v2, const int &dimension1=3, const int &dimension2=3)
Definition: Statistics.cpp:50
unsigned int idNode
Node index in vect_nodes_.
Definition: FTMDataTypes.h:39
The Topology ToolKit.
ftm::FTMTree_MT tree
Definition: FTMTree_MT.h:901