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 numberOfAxes_ = 2;
30 unsigned int k_ = 16;
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 const 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 const 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 axeNumber,
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>> &inputToAxesDistances,
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(axeNumber == 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 < inputToAxesDistances.size(); ++j)
209 distance += inputToAxesDistances[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(axeNumber != 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(axeNumber != 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 axeNumber, 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 = (axeNumber == 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 const 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 void reverseMatchingVector(unsigned int noNodes,
455 std::vector<ftm::idNode> &matchingVector,
456 std::vector<ftm::idNode> &invMatchingVector);
457
458 template <class dataType>
460 std::vector<ftm::idNode> &matchingVector,
461 std::vector<ftm::idNode> &invMatchingVector) {
463 tree.tree.getNumberOfNodes(), matchingVector, invMatchingVector);
464 }
465
466 // m[i][j] contains the node in trees[j] matched to the node i in the
467 // barycenter
468 template <class dataType>
470 ftm::MergeTree<dataType> &barycenter,
471 std::vector<ftm::MergeTree<dataType>> &trees,
472 std::vector<std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>>
473 &matchings,
474 std::vector<std::vector<ftm::idNode>> &matchingMatrix) {
475 matchingMatrix.clear();
476 matchingMatrix.resize(
477 barycenter.tree.getNumberOfNodes(),
478 std::vector<ftm::idNode>(
479 trees.size(), std::numeric_limits<ftm::idNode>::max()));
480 for(unsigned int i = 0; i < trees.size(); ++i) {
481 std::vector<ftm::idNode> matchingVector;
482 getMatchingVector<dataType>(
483 barycenter, trees[i], matchings[i], matchingVector);
484 for(unsigned int j = 0; j < matchingVector.size(); ++j)
485 matchingMatrix[j][i] = matchingVector[j];
486 }
487 }
488
489 template <class dataType>
490 std::tuple<dataType, dataType>
492 return ttk::getParametrizedBirthDeath<dataType>(
493 tree, node, normalizedWasserstein_);
494 }
495
496 //----------------------------------------------------------------------------
497 // Utils
498 //----------------------------------------------------------------------------
499 template <class dataType>
501 ftm::MergeTree<dataType> &barycenter,
502 std::vector<ftm::MergeTree<dataType>> &trees,
503 std::vector<std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>>
504 &baryMatchings,
505 std::vector<std::vector<double>> &allTs,
506 std::vector<std::vector<double>> &branchesCorrelationMatrix,
507 std::vector<std::vector<double>> &persCorrelationMatrix) {
508 branchesCorrelationMatrix.resize(barycenter.tree.getNumberOfNodes(),
509 std::vector<double>(allTs.size(), 0.0));
510 persCorrelationMatrix = branchesCorrelationMatrix;
511
512 // m[i][j] contains the node in trees[j] matched to the node i in the
513 // barycenter
514 std::vector<std::vector<ftm::idNode>> matchingMatrix;
515 getMatchingMatrix(barycenter, trees, baryMatchings, matchingMatrix);
516
517 std::queue<ftm::idNode> queue;
518 queue.emplace(barycenter.tree.getRoot());
519 while(!queue.empty()) {
520 ftm::idNode node = queue.front();
521 queue.pop();
522
523 // Get births and deaths array
524 std::vector<double> births(trees.size(), 0.0),
525 deaths(trees.size(), 0.0), pers(trees.size(), 0.0);
526 for(unsigned int i = 0; i < trees.size(); ++i) {
527 auto matched = matchingMatrix[node][i];
528 std::tuple<dataType, dataType> birthDeath;
529 if(matched == std::numeric_limits<ftm::idNode>::max()) {
530 birthDeath = barycenter.tree.template getBirthDeath<dataType>(node);
531 auto projec
532 = (std::get<0>(birthDeath) + std::get<1>(birthDeath)) / 2.0;
533 birthDeath = std::make_tuple(projec, projec);
534 } else
535 birthDeath
536 = trees[i].tree.template getBirthDeath<dataType>(matched);
537 births[i] = std::get<0>(birthDeath);
538 deaths[i] = std::get<1>(birthDeath);
539 pers[i] = deaths[i] - births[i];
540 }
541
542 // Compute correlations
543 for(unsigned int g = 0; g < allTs.size(); ++g) {
544 double birthCorr = ttk::Statistics::corr(births, allTs[g]);
545 double deathCorr = ttk::Statistics::corr(deaths, allTs[g]);
546 double persCorr = ttk::Statistics::corr(pers, allTs[g]);
547
548 if(std::isnan(birthCorr))
549 birthCorr = 0.0;
550 if(std::isnan(deathCorr))
551 deathCorr = 0.0;
552 if(std::isnan(persCorr))
553 persCorr = 0.0;
554
555 auto birthDeathNode
556 = barycenter.tree.template getBirthDeathNode<dataType>(node);
557 auto birthNode = std::get<0>(birthDeathNode);
558 auto deathNode = std::get<1>(birthDeathNode);
559 branchesCorrelationMatrix[birthNode][g] = birthCorr;
560 branchesCorrelationMatrix[deathNode][g] = deathCorr;
561 persCorrelationMatrix[birthNode][g] = persCorr;
562 persCorrelationMatrix[deathNode][g] = persCorr;
563 }
564
565 // Push children to the queue
566 std::vector<ftm::idNode> children;
567 barycenter.tree.getChildren(node, children);
568 for(auto child : children)
569 queue.emplace(child);
570 }
571 }
572 }; // MergeTreeAxesAlgorithmBase class
573
574} // namespace ttk
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_
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)
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)
void reverseMatchingVector(unsigned int noNodes, std::vector< ftm::idNode > &matchingVector, std::vector< ftm::idNode > &invMatchingVector)
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)
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)
int initVectors(int axeNumber, 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 > > &inputToAxesDistances, 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 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 reverseMatchingVector(ftm::MergeTree< dataType > &tree, std::vector< ftm::idNode > &matchingVector, std::vector< ftm::idNode > &invMatchingVector)
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)
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:735
T magnitudeFlatten(const std::vector< std::vector< T > > &v)
Definition Geometry.cpp:519
T magnitude(const T *v, const int &dimension=3)
Definition Geometry.cpp:509
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:635
T corr(const T *v1, const T *v2, const int &dimension1=3, const int &dimension2=3)
unsigned int idNode
Node index in vect_nodes_.
The Topology ToolKit.
ftm::FTMTree_MT tree
Definition FTMTree_MT.h:903