182 template <
class dataType>
188 template <
class dataType>
191 std::vector<std::vector<dataType>> &distanceMatrix2) {
192 for(
unsigned int i = 0; i < distanceMatrix.size(); ++i)
193 for(
unsigned int j = 0; j < distanceMatrix[i].size(); ++j)
195 distanceMatrix[i][j], distanceMatrix2[i][j]);
202 template <
class dataType>
205 std::vector<std::vector<ftm::idNode>> &treeNodeMerged,
206 bool mergeByPersistence =
false) {
207 bool fullMerge = (epsilon == 100);
210 treeNodeMerged.clear();
214 if(mergeByPersistence)
218 dataType maxValue = tree->
getValue<dataType>(0);
219 dataType minValue = tree->
getValue<dataType>(0);
222 dataType iValue = tree->
getValue<dataType>(i);
223 if(mergeByPersistence) {
224 maxValue = (maxValue < iValue) ? iValue : maxValue;
225 minValue = (minValue > iValue) ? iValue : minValue;
228 dataType parentValue = tree->
getValue<dataType>(parent);
229 dataType tempMax = std::max(iValue, parentValue);
230 dataType tempMin = std::min(iValue, parentValue);
231 if((tempMax - tempMin) > (maxValue - minValue)) {
238 double const epsilonOri = epsilon;
239 epsilon = (maxValue - minValue) * epsilon / 100;
253 for(
unsigned int i = 0; i < farthestSaddle.size(); ++i)
254 farthestSaddle[i] = i;
258 std::stack<int> nodeStack;
259 std::queue<ftm::idNode> queue;
260 queue.emplace(tree->
getRoot());
261 while(!queue.empty()) {
264 nodeStack.emplace(node);
265 std::vector<ftm::idNode> children;
267 for(
auto child : children)
268 queue.emplace(child);
271 while(!nodeStack.empty()) {
276 dataType nodeValue = tree->
getValue<dataType>(nodeId);
278 nodeValue = tree->
getValue<dataType>(farthestSaddle[nodeId]);
279 dataType parentNodeValue = tree->
getValue<dataType>(parentNodeId);
280 dataType diffValue = std::max(nodeValue, parentNodeValue)
281 - std::min(nodeValue, parentNodeValue);
282 if(diffValue <= epsilon) {
284 if(mergeByPersistence) {
286 auto birthDeath2 = tree->
getBirthDeath<dataType>(parentNodeId);
288 = std::get<1>(birthDeath1) - std::get<0>(birthDeath1);
290 = std::get<1>(birthDeath2) - std::get<0>(birthDeath2);
291 nodeIdToDelete = (pers1 > pers2) ? parentNodeId : nodeId;
292 nodeIdToKeep = (pers1 > pers2) ? nodeId : parentNodeId;
293 if(nodeIdToDelete == parentNodeId)
294 nodeStack.emplace(nodeId);
296 nodeIdToDelete = nodeId;
297 nodeIdToKeep = parentNodeId;
300 for(
auto node : treeNodeMerged[nodeIdToDelete]) {
301 treeNodeMerged[nodeIdToKeep].push_back(node);
302 if(isFarthest(farthestSaddle[nodeIdToKeep],
306 treeNodeMerged[nodeIdToKeep].push_back(
308 if(isFarthest(farthestSaddle[nodeIdToKeep], nodeIdToDelete))
309 farthestSaddle[nodeIdToKeep] = nodeIdToDelete;
310 treeNodeMerged[nodeIdToDelete].clear();
324 template <
class dataType>
327 double epsilon3 = 100) {
328 bool fullMerge = (epsilon2 == 0);
334 std::queue<ftm::idNode> queue;
335 queue.emplace(tree->
getRoot());
336 while(!queue.empty()) {
342 const double nodeParentPers
344 if(nodePers / nodeParentPers > epsilon2
345 and nodePers / maxPers < epsilon3)
348 std::vector<ftm::idNode> children;
350 for(
auto child : children)
351 queue.emplace(child);
364 std::vector<ftm::idNode> &nodes) {
365 std::vector<ftm::idSuperArc> arcs;
366 for(
unsigned int i = 0; i < nodes.size(); ++i) {
375 if(!tree->
isRoot(nodeOrigin))
384 template <
class dataType>
386 std::vector<std::tuple<ftm::idNode, ftm::idNode, dataType>> pairs;
389 unsigned int const index = std::max((
int)(pairs.size() - n), 0);
391 std::vector<ftm::idNode> nodes(index);
392 for(
unsigned int i = 0; i < index; ++i)
393 nodes[i] = std::get<0>(pairs[i]);
396 for(
unsigned int i = 0; i < index; ++i) {
406 template <
class dataType>
408 double persistenceThresholdT,
409 std::vector<ftm::idNode> &deletedNodes) {
412 dataType threshold = persistenceThresholdT / 100 * maxPers;
415 bool keepOneZeroPersistencePair = (secondMax == 0 or maxPers == 0);
416 if(threshold >= secondMax)
417 threshold = (1.0 - 1e-6) * secondMax;
419 std::vector<ftm::idNode> nodes;
424 if(nodePers == 0 and keepOneZeroPersistencePair
426 keepOneZeroPersistencePair =
false;
429 if((nodePers == 0 or nodePers <= threshold
434 nodes.emplace_back(i);
435 deletedNodes.push_back(i);
441 deletedNodes.push_back(nodeOrigin);
450 template <
class dataType>
452 std::vector<ftm::idNode> &deletedNodes) {
457 template <
class dataType>
459 double persistenceThresholdT) {
460 std::vector<ftm::idNode> deletedNodes;
462 tree, persistenceThresholdT, deletedNodes);
465 template <
class dataType>
467 std::vector<ftm::idNode> deletedNodes;
472 template <
class dataType>
476 std::stringstream ss;
477 std::vector<ftm::idNode> children;
479 ss << i <<
" has no origin (scalar=" << tree->
getValue<dataType>(i)
480 <<
", noChildren=" << children.size()
486 std::stringstream ss2;
487 ss2 <<
"the root has no origin!";
493 template <
class dataType>
495 bool deleteInconsistentNodes =
true) {
496 if(deleteInconsistentNodes) {
524 template <
class dataType>
527 std::vector<std::vector<ftm::idNode>> &treeNodeMerged) {
540 std::vector<std::vector<ftm::idNode>> treeMultiPers;
545 std::queue<ftm::idNode> queueNodes;
546 queueNodes.emplace(root);
547 while(!queueNodes.empty()) {
551 if(node == nodeOrigin
556 std::vector<std::tuple<ftm::idNode, int>> vecOrigins;
557 for(
auto nodeMergedOrigin : treeNodeMerged[node]) {
558 vecOrigins.emplace_back(nodeMergedOrigin, 0);
559 for(
auto multiPersOrigin :
561 vecOrigins.emplace_back(multiPersOrigin, 1);
564 for(
auto multiPersOrigin : treeMultiPers[node])
565 vecOrigins.emplace_back(multiPersOrigin, 1);
566 vecOrigins.emplace_back(nodeOrigin, 2);
568 bool splitRoot = (vecOrigins.size() != 1 and treeNew->
isRoot(node));
572 for(
auto stackTuple : vecOrigins) {
573 ftm::idNode const nodeOriginT = std::get<0>(stackTuple);
574 int const nodeOriginTID = std::get<1>(stackTuple);
575 if(nodeDone[nodeOriginT]
578 nodeDone[nodeOriginT] =
true;
584 if(nodeOriginTID == 0) {
588 }
else if(nodeOriginTID == 1 or (nodeOriginTID == 2 and splitRoot)) {
589 newParent = nodeOriginT;
594 while(parentNodeOrigin != node) {
597 treeNew->
setParent(parentNodeOrigin, newParent);
598 parentNodeOrigin = oldParentNodeOrigin;
601 if(nodeOriginTID == 1 or (nodeOriginTID == 2 and splitRoot))
606 if(nodeOriginTID == 2 and splitRoot)
610 std::vector<ftm::idNode> childrenNode;
613 if(!treeNew->
isLeaf(children))
614 queueNodes.emplace(children);
624 template <
class dataType>
631 if(nodeIdToDelete != treeRoot
654 std::stringstream ss;
663 std::stringstream ss;
668 template <
class dataType>
671 for(
auto origin : multiPersOrigins)
675 template <
class dataType>
680 bool branchDecompositionT,
683 double persistenceThreshold,
684 std::vector<int> &nodeCorr,
685 bool deleteInconsistentNodes =
true) {
696 std::vector<std::vector<ftm::idNode>> treeNodeMerged(
705 if(branchDecompositionT
715 if(not useMinMaxPairT)
725 tree = &(mTree.
tree);
731 printErr(
"preprocessingPipeline tree->getNumberOfRoot() != 1");
736 std::stringstream ss;
737 ss <<
"TIME PREPROC. = " << t_preproc_time;
741 template <
class dataType>
746 bool branchDecompositionT,
749 std::vector<int> &nodeCorr,
750 bool deleteInconsistentNodes =
true) {
752 mTree, epsilonTree, epsilon2Tree, epsilon3Tree, branchDecompositionT,
754 deleteInconsistentNodes);
759 for(
unsigned int i = 0; i < nodeCorr.size(); ++i)
760 if(nodeCorr[i] >= 0 && nodeCorr[i] < (
int)newNodeCorr.size())
761 newNodeCorr[nodeCorr[i]] = i;
762 nodeCorr = newNodeCorr;
765 template <
class dataType>
770 std::vector<std::vector<ftm::idNode>> treeNodeMerged;
775 template <
class dataType>
782 std::array<double, 3> stats;
784 auto meanNodes = stats[0];
785 unsigned int const n = trees.size();
786 return meanNodes * n;
792 template <
class dataType>
795 bool setOrigins =
false) {
799 dataType newMax = tree1->
getValue<dataType>(root);
801 dataType newMin = tree1->
getValue<dataType>(rootOrigin);
805 std::vector<dataType> newScalarsVector;
807 newScalarsVector[root2] = newMax;
810 if(root2Origin == (
int)root2)
811 root2Origin = mTree2.
tree.template getMergedRootOrigin<dataType>();
813 newScalarsVector.push_back(newMin);
815 newScalarsVector[root2Origin] = newMin;
834 template <
class dataType>
837 return std::make_tuple(-1, -1);
844 dataType oldOriginValue
848 return std::make_tuple(maxIndex, oldOriginValue);
853 template <
class dataType>
858 std::stringstream
const oriPrintTree = tree->
printTree();
859 std::stringstream
const oriPrintPairs
861 std::stringstream
const oriPrintMultiPers
877 and mergedRootOrigin != treeRoot)
880 printErr(
"branchDecompositionToTree mergedRootOrigin inconsistent");
886 auto comp = [&](
const std::tuple<ftm::idNode, dataType> &a,
887 const std::tuple<ftm::idNode, dataType> &b) {
888 return isJT ? std::get<1>(a) > std::get<1>(b)
889 : std::get<1>(a) < std::get<1>(b);
892 std::vector<ftm::idNode> &children) {
893 while(index >= 0 and treeT->isMultiPersPair(children[index]))
899 std::vector<std::tuple<ftm::idNode, ftm::idNode>> nodeParent;
900 std::queue<ftm::idNode> queue;
901 queue.emplace(treeRoot);
902 while(!queue.empty()) {
909 nodeParent.emplace_back(nodeOrigin, node);
911 nodeParent.emplace_back(node, nodeOrigin);
913 nodeParent.emplace_back(node, nodeOrigin);
919 std::vector<ftm::idNode> childrenOri;
921 std::vector<ftm::idNode> children = childrenOri;
922 std::vector<std::tuple<ftm::idNode, dataType>> childrenScalars;
923 for(
unsigned int i = 0; i < children.size(); ++i) {
924 if(isFM and (
int) children[i] != nodeOrigin)
926 childrenScalars.push_back(std::make_tuple(
927 children[i], tree->
getValue<dataType>(children[i])));
929 std::sort(std::begin(childrenScalars), std::end(childrenScalars), comp);
931 for(
unsigned int i = 0; i < childrenScalars.size(); ++i)
932 children.push_back(std::get<0>(childrenScalars[i]));
935 for(
unsigned int i = 1; i < children.size(); ++i) {
938 int const index = getIndexNotMultiPers(i - 1, tree, children);
940 nodeParent.emplace_back(children[i], children[index]);
943 bool const multiPersPair
945 if(not multiPersPair) {
948 = getIndexNotMultiPers(children.size() - 1, tree, children);
949 nodeParent.emplace_back(nodeOrigin, children[index]);
951 nodeParent.emplace_back(children[0], node);
955 nodeParent.emplace_back(children[0], nodeOrigin);
956 int index = getIndexNotMultiPers(children.size() - 1, tree, children);
958 printErr(
"[branchDecompositionToTree] index < 0");
961 nodeParent.emplace_back(node, children[index]);
965 for(
auto child : childrenOri)
966 queue.emplace(child);
970 for(
auto nodeParentT : nodeParent)
971 tree->
setParent(std::get<0>(nodeParentT), std::get<1>(nodeParentT));
981 std::stringstream ss;
983 ss << i <<
" _ " << iOrigin;
989 printErr(
"[branchDecompositionToTree] 1 up arc and 1 down arc");
994 template <
class dataType>
997 std::queue<ftm::idNode> queue;
998 queue.emplace(tree->
getRoot());
999 while(!queue.empty()) {
1003 if(!tree->
isLeaf(node)) {
1004 std::vector<ftm::idNode> children;
1006 std::vector<ftm::idNode> lowestNodes;
1008 for(
auto child : children) {
1010 lowestNodes.push_back(lowestNode);
1014 and lowestNodeOrigin != node)
1015 branchOrigin = lowestNode;
1017 for(
size_t i = 0; i < children.size(); ++i) {
1020 if(branchOrigin == lowestNodes[i] or lowestNodeOrigin == node)
1022 dataType lowestNodeOriginVal
1023 = tree->
getValue<dataType>(lowestNodeOrigin);
1027 while(branchRoot != branchOriginT) {
1030 if((val > lowestNodeOriginVal and isJT)
1031 or (val < lowestNodeOriginVal and not isJT))
1037 tree->
setParent(branchOriginT, lowestNodeOrigin);
1038 tree->
setParent(children[i], lowestNodeOrigin);
1041 std::vector<ftm::idNode> children;
1043 for(
auto child : children)
1044 queue.emplace(child);
1048 template <
class dataType>
1058 "[postprocessingPipeline] mergedRootOrigin inconsistent id.");
1070 template <
class dataType>
1074 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>
1076 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> toAdd;
1077 for(
auto mTuple : outputMatching) {
1080 double const cost = std::get<2>(mTuple);
1085 int const node1OriginLevel = tree1->
getNodeLevel(node1Origin);
1087 int const node2OriginLevel = tree2->
getNodeLevel(node2Origin);
1090 = (node1Level > node1OriginLevel) ? node1 : node1Origin;
1092 = (node1Level > node1OriginLevel) ? node1Origin : node1;
1094 = (node2Level > node2OriginLevel) ? node2 : node2Origin;
1096 = (node2Level > node2OriginLevel) ? node2Origin : node2;
1104 toAdd.emplace_back(node1Higher, node2Higher, cost);
1106 toAdd.emplace_back(node1Lower, node2Lower, cost);
1108 outputMatching.clear();
1109 outputMatching.insert(outputMatching.end(), toAdd.begin(), toAdd.end());
1112 template <
class dataType>
1116 std::vector<std::tuple<ftm::idNode, ftm::idNode>> &outputMatching) {
1117 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>
1118 realOutputMatching(outputMatching.size());
1119 for(
size_t i = 0; i < outputMatching.size(); ++i) {
1120 const auto &tup{outputMatching[i]};
1121 realOutputMatching[i] = {std::get<0>(tup), std::get<1>(tup), 0.0};
1125 tree1, tree2, realOutputMatching);
1127 outputMatching.clear();
1128 for(
auto tup : realOutputMatching)
1129 outputMatching.emplace_back(std::get<0>(tup), std::get<1>(tup));
1132 template <
class dataType>
1136 std::vector<std::tuple<ftm::idNode, ftm::idNode>> &outputMatching,
1137 std::vector<std::tuple<ftm::idNode, ftm::idNode, bool>> &realMatching) {
1138 for(std::tuple<ftm::idNode, ftm::idNode> mTuple : outputMatching) {
1141 dataType relabelCostVal
1145 bool isRealMatching = (relabelCostVal <= deleteInsertCostVal);
1146 realMatching.emplace_back(tree1Node, tree2Node, isRealMatching);
1153 template <
class dataType>
1155 dataType x1, dataType x2, dataType y1, dataType y2,
double power = 2) {
1158 std::abs((
double)(x1 - y1)), std::abs((
double)(x2 - y2)));
1160 return std::pow(std::abs((
double)(x1 - y1)), power)
1161 + std::pow(std::abs((
double)(x2 - y2)), power);
1164 template <
class dataType>
1167 dataType newMin = 0.0, newMax = 1.0;
1173 dataType birth = std::get<0>(birthDeath);
1174 dataType death = std::get<1>(birthDeath);
1175 dataType projec = (birth + death) / 2;
1187 template <
class dataType>
1192 template <
class dataType>
1198 dataType newMin = 0.0, newMax = 1.0;
1204 dataType birth1 = std::get<0>(birthDeath1);
1205 dataType death1 = std::get<1>(birthDeath1);
1211 dataType birth2 = std::get<0>(birthDeath2);
1212 dataType death2 = std::get<1>(birthDeath2);
1223 template <
class dataType>
1240 if(deleteInsertCost < cost)
1241 cost = deleteInsertCost;
1251 paramNames = std::vector<std::string>{
"epsilon1",
1254 "persistenceThreshold",
1255 "branchDecomposition",
1256 "normalizedWasserstein",
1258 "isPersistenceDiagram",
1259 "deleteMultiPersPairs",
1260 "epsilon1UseFarthestSaddle",
1261 "mixtureCoefficient"};
1266 if(paramName ==
"epsilon1")
1268 else if(paramName ==
"epsilon2")
1270 else if(paramName ==
"epsilon3")
1272 else if(paramName ==
"persistenceThreshold")
1274 else if(paramName ==
"branchDecomposition")
1276 else if(paramName ==
"normalizedWasserstein")
1278 else if(paramName ==
"keepSubtree")
1280 else if(paramName ==
"isPersistenceDiagram")
1282 else if(paramName ==
"deleteMultiPersPairs")
1284 else if(paramName ==
"epsilon1UseFarthestSaddle")
1286 else if(paramName ==
"mixtureCoefficient")
1292 if(paramName ==
"epsilon1")
1294 else if(paramName ==
"epsilon2")
1296 else if(paramName ==
"epsilon3")
1298 else if(paramName ==
"persistenceThreshold")
1300 else if(paramName ==
"branchDecomposition")
1302 else if(paramName ==
"normalizedWasserstein")
1304 else if(paramName ==
"keepSubtree")
1306 else if(paramName ==
"isPersistenceDiagram")
1308 else if(paramName ==
"deleteMultiPersPairs")
1310 else if(paramName ==
"epsilon1UseFarthestSaddle")
1312 else if(paramName ==
"mixtureCoefficient")
1317 std::array<double, 3> &stats) {
1318 double avgNodes = 0, avgNodesT = 0;
1319 double avgDepth = 0;
1320 for(
unsigned int i = 0; i < trees.size(); ++i) {
1321 auto noNodesT = trees[i]->getNumberOfNodes();
1322 auto noNodes = trees[i]->getRealNumberOfNodes();
1323 avgNodes += noNodes;
1324 avgNodesT += noNodesT;
1325 avgDepth += trees[i]->getTreeDepth();
1327 avgNodes /= trees.size();
1328 avgNodesT /= trees.size();
1329 avgDepth /= trees.size();
1331 stats = {avgNodes, avgNodesT, avgDepth};
1335 std::array<double, 3> stats;
1337 int avgNodes = stats[0], avgNodesT = stats[1];
1338 double const avgDepth = stats[2];
1339 std::stringstream ss;
1340 ss << trees.size() <<
" trees average [node: " << avgNodes <<
" / "
1341 << avgNodesT <<
", depth: " << avgDepth <<
"]";
1345 template <
class dataType>
1347 std::vector<ftm::FTMTree_MT *> treesT;
1352 template <
class dataType>
1354 std::streamsize
const ssize = std::cout.precision();
1355 std::stringstream ss;
1357 for(
unsigned int j = 0; j < table[0].size(); ++j)
1362 for(
unsigned int i = 0; i < table.size(); ++i) {
1363 ss << std::setw(3) << std::setfill(
'0') << std::internal << i - 1
1365 for(
unsigned int j = 0; j < table[0].size(); ++j) {
1366 ss << std::fixed << std::setprecision(2) << table[i][j] <<
" ";
1371 std::cout.precision(ssize);
1375 template <
class dataType>
1377 std::vector<std::vector<dataType>> vec(nRows, std::vector<dataType>());
1378 for(
int i = 0; i < nRows; ++i)
1379 for(
int j = 0; j < nCols; ++j)
1380 vec[i].push_back(table[i * nCols + j]);
1386 for(
const auto &mTuple : matchings) {
1387 std::stringstream ss;
1388 ss << std::get<0>(mTuple) <<
" - " << std::get<1>(mTuple) <<
" - "
1389 << std::get<2>(mTuple);
1396 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> &matchings) {
1398 for(
auto mTuple : matchings) {
1399 std::stringstream ss;
1400 ss << std::get<0>(mTuple) <<
" - " << std::get<1>(mTuple);
1407 std::vector<std::tuple<ftm::idNode, ftm::idNode>> &matchings) {
1408 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> matchingsT(
1410 for(
size_t i = 0; i < matchings.size(); ++i) {
1411 const auto &tup{matchings[i]};
1412 matchingsT[i] = {std::get<0>(tup), std::get<1>(tup), 0.0};
1417 template <
class dataType>
1419 std::vector<std::tuple<SimplexId, SimplexId, dataType>> &treePairs) {
1420 for(
auto pair : treePairs) {
1421 std::stringstream
const ss;
1422 ss << std::get<0>(pair) <<
" _ " << std::get<1>(pair) <<
" _ "
1423 << std::get<2>(pair);
1429 template <
class dataType>
1431 std::vector<std::tuple<ftm::idNode, ftm::idNode>> &outputMatching,
1434 bool computeCosts =
true) {
1438 std::stringstream ss;
1439 for(std::tuple<ftm::idNode, ftm::idNode> matching : outputMatching) {
1444 ss << node0 <<
" - " << node1 <<
" _ [ ";
1445 ss <<
"f(" << node0 <<
")=" << tree1->
getValue<dataType>(node0)
1447 ss <<
"g(" << node1 <<
")=" << tree2->
getValue<dataType>(node1) <<
" ]"
1449 ss <<
"f(" << node0Origin
1450 <<
")=" << tree1->
getValue<dataType>(node0Origin) <<
" _ ";
1451 ss <<
"g(" << node1Origin
1452 <<
")=" << tree2->
getValue<dataType>(node1Origin) <<
" ] ";
1458 ss <<
"cost = " << tempCost <<
" (" << tempCost2 <<
")" << std::endl;
1462 tree1Done[node0] =
true;
1463 tree2Done[node1] =
true;
1467 if(not tree1Done[i] and not tree1->
isNodeAlone(i)) {
1469 ss <<
"T1 " << i <<
" _ [ f(" << i
1470 <<
") = " << tree1->
getValue<dataType>(i);
1471 ss <<
"_ f(" << nodeOrigin
1472 <<
") = " << tree1->
getValue<dataType>(nodeOrigin);
1476 ss <<
" _ cost = " << tempCost << std::endl;
1482 if(not tree2Done[i] and not tree2->
isNodeAlone(i)) {
1484 ss <<
"T2 " << i <<
" _ [ g(" << i
1485 <<
") = " << tree2->
getValue<dataType>(i);
1486 ss <<
"_ g(" << nodeOrigin
1487 <<
") = " << tree2->
getValue<dataType>(nodeOrigin);
1491 ss <<
" _ cost = " << tempCost << std::endl;
1497 ss <<
"total cost = " << cost <<
" (" << std::sqrt(cost) <<
")"
void setDebugMsgPrefix(const std::string &prefix)
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
void printTable(dataType *table, int nRows, int nCols)
void setBranchDecomposition(bool useBD)
void setNormalizedWasserstein(bool normalizedWasserstein)
void setDistanceSquaredRoot(bool distanceSquaredRoot)
double mixtureCoefficient_
void getTreesStats(std::vector< ftm::FTMTree_MT * > &trees, std::array< double, 3 > &stats)
void setParamValueFromName(std::string ¶mName, double value)
bool epsilon1UseFarthestSaddle_
bool barycenterMergeTree_
void setUseDoubleInput(const bool useDoubleInput)
void printTreesStats(std::vector< ftm::MergeTree< dataType > > &trees)
void setEpsilon3Tree1(double epsilon)
void setEpsilonTree1(double epsilon)
void setAssignmentSolver(int assignmentSolver)
void persistenceThresholding(ftm::FTMTree_MT *tree)
dataType computeDistance(dataType x1, dataType x2, dataType y1, dataType y2, double power=2)
dataType deleteCost(const ftm::FTMTree_MT *tree, ftm::idNode nodeId)
void deleteMultiPersPairs(ftm::FTMTree_MT *tree, bool useBD)
void printOutputMatching(std::vector< std::tuple< ftm::idNode, ftm::idNode > > &outputMatching, ftm::FTMTree_MT *tree1, ftm::FTMTree_MT *tree2, bool computeCosts=true)
void mtFlattening(ftm::MergeTree< dataType > &mt)
void mergeSaddle(ftm::FTMTree_MT *tree, double epsilon, std::vector< std::vector< ftm::idNode > > &treeNodeMerged, bool mergeByPersistence=false)
void preprocessingPipeline(ftm::MergeTree< dataType > &mTree, double epsilonTree, double epsilon2Tree, double epsilon3Tree, bool branchDecompositionT, bool useMinMaxPairT, bool cleanTreeT, double persistenceThreshold, std::vector< int > &nodeCorr, bool deleteInconsistentNodes=true)
void keepMostImportantPairs(ftm::FTMTree_MT *tree, int n, bool useBD)
double mixDistancesWeight(bool isFirstInput)
void setNodePerTask(int npt)
void convertBranchDecompositionMatching(ftm::FTMTree_MT *tree1, ftm::FTMTree_MT *tree2, std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > &outputMatching)
std::vector< std::vector< int > > getTreesNodeCorr()
void getParamNames(std::vector< std::string > ¶mNames)
void putBackMergedNodes(ftm::FTMTree_MT *tree)
void dontUseMinMaxPair(ftm::FTMTree_MT *tree)
void setEpsilon2Tree1(double epsilon)
void setEpsilonTree2(double epsilon)
void setBarycenterMergeTree(bool imt)
bool normalizedWasserstein_
ftm::FTMTree_MT * computeBranchDecomposition(ftm::FTMTree_MT *tree, std::vector< std::vector< ftm::idNode > > &treeNodeMerged)
void printMatching(std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > &matchings)
dataType relabelCost(const ftm::FTMTree_MT *tree1, ftm::idNode nodeId1, const ftm::FTMTree_MT *tree2, ftm::idNode nodeId2)
void verifyOrigins(ftm::FTMTree_MT *tree)
double mixDistances(dataType distance1, dataType distance2)
void printMatching(std::vector< std::tuple< ftm::idNode, ftm::idNode > > &matchings)
void persistenceThresholding(ftm::FTMTree_MT *tree, std::vector< ftm::idNode > &deletedNodes)
void branchDecompositionToTree(ftm::FTMTree_MT *tree)
void persistenceThresholding(ftm::FTMTree_MT *tree, double persistenceThresholdT)
void deletePersistenceDiagramsPairs(ftm::FTMTree_MT *tree, std::vector< ftm::idNode > &nodes)
double getSizeLimitMetric(std::vector< ftm::FTMTree_MT * > &trees)
bool deleteMultiPersPairs_
void preprocessingPipeline(ftm::MergeTree< dataType > &mTree, double epsilonTree, double epsilon2Tree, double epsilon3Tree, bool branchDecompositionT, bool useMinMaxPairT, bool cleanTreeT, std::vector< int > &nodeCorr, bool deleteInconsistentNodes=true)
void setPersistenceThreshold(double pt)
void printTreesStats(std::vector< ftm::FTMTree_MT * > &trees)
void postprocessingPipeline(ftm::FTMTree_MT *tree)
bool distanceSquaredRoot_
void printTableVector(std::vector< std::vector< dataType > > &table)
void verifyPairsTree(ftm::FTMTree_MT *tree)
void setNonMatchingWeight(double weight)
void printMatching(std::vector< MatchingType > &matchings)
void printPairs(std::vector< std::tuple< SimplexId, SimplexId, dataType > > &treePairs)
void copyMinMaxPair(ftm::MergeTree< dataType > &mTree1, ftm::MergeTree< dataType > &mTree2, bool setOrigins=false)
double nonMatchingWeight_
std::vector< std::vector< int > > treesNodeCorr_
void preprocessTree(ftm::FTMTree_MT *tree, bool deleteInconsistentNodes=true)
void setCleanTree(bool clean)
void reverseNodeCorr(ftm::FTMTree_MT *tree, std::vector< int > &nodeCorr)
void identifyRealMatching(ftm::FTMTree_MT *tree1, ftm::FTMTree_MT *tree2, std::vector< std::tuple< ftm::idNode, ftm::idNode > > &outputMatching, std::vector< std::tuple< ftm::idNode, ftm::idNode, bool > > &realMatching)
void setJoinSplitMixtureCoefficient(const double mixtureCoefficient)
dataType relabelCostOnly(const ftm::FTMTree_MT *tree1, ftm::idNode nodeId1, const ftm::FTMTree_MT *tree2, ftm::idNode nodeId2)
void setEpsilon2Tree2(double epsilon)
void setKeepSubtree(bool keepSubtree)
double persistenceThreshold_
void persistenceThresholding(ftm::FTMTree_MT *tree, double persistenceThresholdT, std::vector< ftm::idNode > &deletedNodes)
void persistenceMerging(ftm::FTMTree_MT *tree, double epsilon2, double epsilon3=100)
void mtsFlattening(std::vector< ftm::MergeTree< dataType > > &mts)
void setEpsilon1UseFarthestSaddle(bool b)
void setDeleteMultiPersPairs(bool deleteMultiPersPairsT)
void setUseMinMaxPair(bool useMinMaxPair)
void setEpsilon3Tree2(double epsilon)
double mixDistancesMinMaxPairWeight(bool isFirstInput)
bool branchDecomposition_
bool isPersistenceDiagram_
dataType insertCost(const ftm::FTMTree_MT *tree, ftm::idNode nodeId)
void setParallelize(bool para)
double getParamValueFromName(std::string ¶mName)
void setIsPersistenceDiagram(bool isPD)
void convertBranchDecompositionMatching(ftm::FTMTree_MT *tree1, ftm::FTMTree_MT *tree2, std::vector< std::tuple< ftm::idNode, ftm::idNode > > &outputMatching)
std::tuple< int, dataType > fixMergedRootOrigin(ftm::FTMTree_MT *tree)
void mixDistancesMatrix(std::vector< std::vector< dataType > > &distanceMatrix, std::vector< std::vector< dataType > > &distanceMatrix2)
std::stringstream printMultiPersPairsFromTree(bool useBD=false, bool printPairs=true, bool doPrint=true) const
void getMultiPersOriginsVectorFromTree(std::vector< std::vector< idNode > > &res) const
Node * getNode(idNode nodeId) const
std::stringstream printTree(bool doPrint=true) const
const scalarType & getValue(SimplexId nodeId) const
void getChildren(idNode nodeId, std::vector< idNode > &res) const
idNode getNumberOfNodes() const
bool isMultiPersPair(idNode nodeId) const
void setParent(idNode nodeId, idNode newParentNodeId)
int getNodeLevel(idNode nodeId) const
idNode getLowestNode(idNode nodeStart) const
idNode getParentSafe(idNode nodeId) const
std::vector< ftm::idNode > getMultiPersOrigins(bool useBD) const
idNode getMergedRootOrigin() const
dataType getMaximumPersistence() const
dataType getSecondMaximumPersistence() const
int getRealNumberOfNodes() const
dataType getNodePersistence(idNode nodeId) const
std::stringstream printPairsFromTree(bool useBD=false, bool printPairs=true, bool doPrint=true) const
bool isNodeOriginDefined(idNode nodeId) const
bool isLeaf(idNode nodeId) const
void deleteNode(idNode nodeId)
bool isRoot(idNode nodeId) const
std::tuple< dataType, dataType > getBirthDeath(idNode nodeId) const
bool isNodeIdInconsistent(idNode nodeId) const
int getNumberOfRoot() const
idNode makeNode(SimplexId vertexId, SimplexId linked=nullVertex)
bool isNodeAlone(idNode nodeId) const
void getPersistencePairsFromTree(std::vector< std::tuple< ftm::idNode, ftm::idNode, dataType > > &pairs, bool useBD) const
bool isNodeMerged(idNode nodeId) const
bool isThereOnlyOnePersistencePair() const
idSuperArc getUpSuperArcId(idSuperArc neighborId) const
idSuperArc clearUpSuperArcs()
idSuperArc getNumberOfDownSuperArcs() const
idSuperArc clearDownSuperArcs()
void setOrigin(SimplexId linked)
SimplexId getOrigin() const
idSuperArc getNumberOfUpSuperArcs() const
void removeDownSuperArcs(std::vector< idSuperArc > &idSa)
void setTreeScalars(MergeTree< dataType > &mergeTree, std::vector< dataType > &scalarsVector)
MergeTree< dataType > cleanMergeTree(ftm::FTMTree_MT *tree, std::vector< int > &nodeCorr, bool useBD=true)
void getTreeScalars(const ftm::FTMTree_MT *tree, std::vector< dataType > &scalarsVector)
void mergeTreeToFTMTree(std::vector< MergeTree< dataType > > &trees, std::vector< ftm::FTMTree_MT * > &treesT)
unsigned int idNode
Node index in vect_nodes_.
std::vector< std::tuple< SimplexId, SimplexId, dataType > > computePersistencePairs(FTMTree_MT *tree)
TTK base package defining the standard types.
std::tuple< dataType, dataType > getNormalizedBirthDeath(const ftm::FTMTree_MT *tree, ftm::idNode nodeId, dataType newMin=0.0, dataType newMax=1.0)
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/| (_) |"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)