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,
686 bool removeMergedSaddles =
false) {
697 std::vector<std::vector<ftm::idNode>> treeNodeMerged(
700 if(epsilonTree != 0) {
702 if(removeMergedSaddles) {
703 for(
unsigned int j = 0; j < treeNodeMerged.size(); j++) {
704 for(
auto k : treeNodeMerged[j]) {
716 if(branchDecompositionT
726 if(not useMinMaxPairT)
736 tree = &(mTree.
tree);
742 printErr(
"preprocessingPipeline tree->getNumberOfRoot() != 1");
747 std::stringstream ss;
748 ss <<
"TIME PREPROC. = " << t_preproc_time;
752 template <
class dataType>
757 bool branchDecompositionT,
760 std::vector<int> &nodeCorr,
761 bool deleteInconsistentNodes =
true,
762 bool removeMergedSaddles =
false) {
764 mTree, epsilonTree, epsilon2Tree, epsilon3Tree, branchDecompositionT,
766 deleteInconsistentNodes, removeMergedSaddles);
771 for(
unsigned int i = 0; i < nodeCorr.size(); ++i)
772 if(nodeCorr[i] >= 0 && nodeCorr[i] < (
int)newNodeCorr.size())
773 newNodeCorr[nodeCorr[i]] = i;
774 nodeCorr = newNodeCorr;
777 template <
class dataType>
782 std::vector<std::vector<ftm::idNode>> treeNodeMerged;
787 template <
class dataType>
794 std::array<double, 3> stats;
796 auto meanNodes = stats[0];
797 unsigned int const n = trees.size();
798 return meanNodes * n;
804 template <
class dataType>
807 bool setOrigins =
false) {
811 dataType newMax = tree1->
getValue<dataType>(root);
813 dataType newMin = tree1->
getValue<dataType>(rootOrigin);
817 std::vector<dataType> newScalarsVector;
819 newScalarsVector[root2] = newMax;
822 if(root2Origin == (
int)root2)
823 root2Origin = mTree2.
tree.template getMergedRootOrigin<dataType>();
825 newScalarsVector.push_back(newMin);
827 newScalarsVector[root2Origin] = newMin;
846 template <
class dataType>
849 return std::make_tuple(-1, -1);
856 dataType oldOriginValue
860 return std::make_tuple(maxIndex, oldOriginValue);
865 template <
class dataType>
870 std::stringstream
const oriPrintTree = tree->
printTree();
871 std::stringstream
const oriPrintPairs
873 std::stringstream
const oriPrintMultiPers
889 and mergedRootOrigin != treeRoot)
892 printErr(
"branchDecompositionToTree mergedRootOrigin inconsistent");
898 auto comp = [&](
const std::tuple<ftm::idNode, dataType> &a,
899 const std::tuple<ftm::idNode, dataType> &b) {
900 return isJT ? std::get<1>(a) > std::get<1>(b)
901 : std::get<1>(a) < std::get<1>(b);
904 std::vector<ftm::idNode> &children) {
905 while(index >= 0 and treeT->isMultiPersPair(children[index]))
911 std::vector<std::tuple<ftm::idNode, ftm::idNode>> nodeParent;
912 std::queue<ftm::idNode> queue;
913 queue.emplace(treeRoot);
914 while(!queue.empty()) {
921 nodeParent.emplace_back(nodeOrigin, node);
923 nodeParent.emplace_back(node, nodeOrigin);
925 nodeParent.emplace_back(node, nodeOrigin);
931 std::vector<ftm::idNode> childrenOri;
933 std::vector<ftm::idNode> children = childrenOri;
934 std::vector<std::tuple<ftm::idNode, dataType>> childrenScalars;
935 for(
unsigned int i = 0; i < children.size(); ++i) {
936 if(isFM and (
int) children[i] != nodeOrigin)
938 childrenScalars.push_back(std::make_tuple(
939 children[i], tree->
getValue<dataType>(children[i])));
941 std::sort(std::begin(childrenScalars), std::end(childrenScalars), comp);
943 for(
unsigned int i = 0; i < childrenScalars.size(); ++i)
944 children.push_back(std::get<0>(childrenScalars[i]));
947 for(
unsigned int i = 1; i < children.size(); ++i) {
950 int const index = getIndexNotMultiPers(i - 1, tree, children);
952 nodeParent.emplace_back(children[i], children[index]);
955 bool const multiPersPair
957 if(not multiPersPair) {
960 = getIndexNotMultiPers(children.size() - 1, tree, children);
961 nodeParent.emplace_back(nodeOrigin, children[index]);
963 nodeParent.emplace_back(children[0], node);
967 nodeParent.emplace_back(children[0], nodeOrigin);
968 int index = getIndexNotMultiPers(children.size() - 1, tree, children);
970 printErr(
"[branchDecompositionToTree] index < 0");
973 nodeParent.emplace_back(node, children[index]);
977 for(
auto child : childrenOri)
978 queue.emplace(child);
982 for(
auto nodeParentT : nodeParent)
983 tree->
setParent(std::get<0>(nodeParentT), std::get<1>(nodeParentT));
993 std::stringstream ss;
995 ss << i <<
" _ " << iOrigin;
1001 printErr(
"[branchDecompositionToTree] 1 up arc and 1 down arc");
1006 template <
class dataType>
1009 std::queue<ftm::idNode> queue;
1010 queue.emplace(tree->
getRoot());
1011 while(!queue.empty()) {
1015 if(!tree->
isLeaf(node)) {
1016 std::vector<ftm::idNode> children;
1018 std::vector<ftm::idNode> lowestNodes;
1020 for(
auto child : children) {
1022 lowestNodes.push_back(lowestNode);
1026 and lowestNodeOrigin != node)
1027 branchOrigin = lowestNode;
1029 for(
size_t i = 0; i < children.size(); ++i) {
1032 if(branchOrigin == lowestNodes[i] or lowestNodeOrigin == node)
1034 dataType lowestNodeOriginVal
1035 = tree->
getValue<dataType>(lowestNodeOrigin);
1039 while(branchRoot != branchOriginT) {
1042 if((val > lowestNodeOriginVal and isJT)
1043 or (val < lowestNodeOriginVal and not isJT))
1049 tree->
setParent(branchOriginT, lowestNodeOrigin);
1050 tree->
setParent(children[i], lowestNodeOrigin);
1053 std::vector<ftm::idNode> children;
1055 for(
auto child : children)
1056 queue.emplace(child);
1060 template <
class dataType>
1070 "[postprocessingPipeline] mergedRootOrigin inconsistent id.");
1082 template <
class dataType>
1086 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>
1088 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> toAdd;
1089 for(
auto mTuple : outputMatching) {
1092 double const cost = std::get<2>(mTuple);
1097 int const node1OriginLevel = tree1->
getNodeLevel(node1Origin);
1099 int const node2OriginLevel = tree2->
getNodeLevel(node2Origin);
1102 = (node1Level > node1OriginLevel) ? node1 : node1Origin;
1104 = (node1Level > node1OriginLevel) ? node1Origin : node1;
1106 = (node2Level > node2OriginLevel) ? node2 : node2Origin;
1108 = (node2Level > node2OriginLevel) ? node2Origin : node2;
1116 toAdd.emplace_back(node1Higher, node2Higher, cost);
1118 toAdd.emplace_back(node1Lower, node2Lower, cost);
1120 outputMatching.clear();
1121 outputMatching.insert(outputMatching.end(), toAdd.begin(), toAdd.end());
1124 template <
class dataType>
1128 std::vector<std::tuple<ftm::idNode, ftm::idNode>> &outputMatching) {
1129 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>
1130 realOutputMatching(outputMatching.size());
1131 for(
size_t i = 0; i < outputMatching.size(); ++i) {
1132 const auto &tup{outputMatching[i]};
1133 realOutputMatching[i] = {std::get<0>(tup), std::get<1>(tup), 0.0};
1137 tree1, tree2, realOutputMatching);
1139 outputMatching.clear();
1140 for(
auto tup : realOutputMatching)
1141 outputMatching.emplace_back(std::get<0>(tup), std::get<1>(tup));
1144 template <
class dataType>
1148 std::vector<std::tuple<ftm::idNode, ftm::idNode>> &outputMatching,
1149 std::vector<std::tuple<ftm::idNode, ftm::idNode, bool>> &realMatching) {
1150 for(std::tuple<ftm::idNode, ftm::idNode> mTuple : outputMatching) {
1153 dataType relabelCostVal
1157 bool isRealMatching = (relabelCostVal <= deleteInsertCostVal);
1158 realMatching.emplace_back(tree1Node, tree2Node, isRealMatching);
1165 template <
class dataType>
1167 dataType x1, dataType x2, dataType y1, dataType y2,
double power = 2) {
1170 std::abs((
double)(x1 - y1)), std::abs((
double)(x2 - y2)));
1172 return std::pow(std::abs((
double)(x1 - y1)), power)
1173 + std::pow(std::abs((
double)(x2 - y2)), power);
1176 template <
class dataType>
1179 dataType newMin = 0.0, newMax = 1.0;
1185 dataType birth = std::get<0>(birthDeath);
1186 dataType death = std::get<1>(birthDeath);
1187 dataType projec = (birth + death) / 2;
1199 template <
class dataType>
1204 template <
class dataType>
1210 dataType newMin = 0.0, newMax = 1.0;
1216 dataType birth1 = std::get<0>(birthDeath1);
1217 dataType death1 = std::get<1>(birthDeath1);
1223 dataType birth2 = std::get<0>(birthDeath2);
1224 dataType death2 = std::get<1>(birthDeath2);
1235 template <
class dataType>
1252 if(deleteInsertCost < cost)
1253 cost = deleteInsertCost;
1263 paramNames = std::vector<std::string>{
"epsilon1",
1266 "persistenceThreshold",
1267 "branchDecomposition",
1268 "normalizedWasserstein",
1270 "isPersistenceDiagram",
1271 "deleteMultiPersPairs",
1272 "epsilon1UseFarthestSaddle",
1273 "mixtureCoefficient"};
1278 if(paramName ==
"epsilon1")
1280 else if(paramName ==
"epsilon2")
1282 else if(paramName ==
"epsilon3")
1284 else if(paramName ==
"persistenceThreshold")
1286 else if(paramName ==
"branchDecomposition")
1288 else if(paramName ==
"normalizedWasserstein")
1290 else if(paramName ==
"keepSubtree")
1292 else if(paramName ==
"isPersistenceDiagram")
1294 else if(paramName ==
"deleteMultiPersPairs")
1296 else if(paramName ==
"epsilon1UseFarthestSaddle")
1298 else if(paramName ==
"mixtureCoefficient")
1304 if(paramName ==
"epsilon1")
1306 else if(paramName ==
"epsilon2")
1308 else if(paramName ==
"epsilon3")
1310 else if(paramName ==
"persistenceThreshold")
1312 else if(paramName ==
"branchDecomposition")
1314 else if(paramName ==
"normalizedWasserstein")
1316 else if(paramName ==
"keepSubtree")
1318 else if(paramName ==
"isPersistenceDiagram")
1320 else if(paramName ==
"deleteMultiPersPairs")
1322 else if(paramName ==
"epsilon1UseFarthestSaddle")
1324 else if(paramName ==
"mixtureCoefficient")
1329 std::array<double, 3> &stats) {
1330 double avgNodes = 0, avgNodesT = 0;
1331 double avgDepth = 0;
1332 for(
unsigned int i = 0; i < trees.size(); ++i) {
1333 auto noNodesT = trees[i]->getNumberOfNodes();
1334 auto noNodes = trees[i]->getRealNumberOfNodes();
1335 avgNodes += noNodes;
1336 avgNodesT += noNodesT;
1337 avgDepth += trees[i]->getTreeDepth();
1339 avgNodes /= trees.size();
1340 avgNodesT /= trees.size();
1341 avgDepth /= trees.size();
1343 stats = {avgNodes, avgNodesT, avgDepth};
1347 std::array<double, 3> stats;
1349 int avgNodes = stats[0], avgNodesT = stats[1];
1350 double const avgDepth = stats[2];
1351 std::stringstream ss;
1352 ss << trees.size() <<
" trees average [node: " << avgNodes <<
" / "
1353 << avgNodesT <<
", depth: " << avgDepth <<
"]";
1357 template <
class dataType>
1359 std::vector<ftm::FTMTree_MT *> treesT;
1364 template <
class dataType>
1366 std::streamsize
const ssize = std::cout.precision();
1367 std::stringstream ss;
1369 for(
unsigned int j = 0; j < table[0].size(); ++j)
1374 for(
unsigned int i = 0; i < table.size(); ++i) {
1375 ss << std::setw(3) << std::setfill(
'0') << std::internal << i - 1
1377 for(
unsigned int j = 0; j < table[0].size(); ++j) {
1378 ss << std::fixed << std::setprecision(2) << table[i][j] <<
" ";
1383 std::cout.precision(ssize);
1387 template <
class dataType>
1389 std::vector<std::vector<dataType>> vec(nRows, std::vector<dataType>());
1390 for(
int i = 0; i < nRows; ++i)
1391 for(
int j = 0; j < nCols; ++j)
1392 vec[i].push_back(table[i * nCols + j]);
1398 for(
const auto &mTuple : matchings) {
1399 std::stringstream ss;
1400 ss << std::get<0>(mTuple) <<
" - " << std::get<1>(mTuple) <<
" - "
1401 << std::get<2>(mTuple);
1408 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> &matchings) {
1410 for(
auto mTuple : matchings) {
1411 std::stringstream ss;
1412 ss << std::get<0>(mTuple) <<
" - " << std::get<1>(mTuple);
1419 std::vector<std::tuple<ftm::idNode, ftm::idNode>> &matchings) {
1420 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> matchingsT(
1422 for(
size_t i = 0; i < matchings.size(); ++i) {
1423 const auto &tup{matchings[i]};
1424 matchingsT[i] = {std::get<0>(tup), std::get<1>(tup), 0.0};
1429 template <
class dataType>
1431 std::vector<std::tuple<SimplexId, SimplexId, dataType>> &treePairs) {
1432 for(
auto pair : treePairs) {
1433 std::stringstream
const ss;
1434 ss << std::get<0>(pair) <<
" _ " << std::get<1>(pair) <<
" _ "
1435 << std::get<2>(pair);
1441 template <
class dataType>
1443 std::vector<std::tuple<ftm::idNode, ftm::idNode>> &outputMatching,
1446 bool computeCosts =
true) {
1450 std::stringstream ss;
1451 for(std::tuple<ftm::idNode, ftm::idNode> matching : outputMatching) {
1456 ss << node0 <<
" - " << node1 <<
" _ [ ";
1457 ss <<
"f(" << node0 <<
")=" << tree1->
getValue<dataType>(node0)
1459 ss <<
"g(" << node1 <<
")=" << tree2->
getValue<dataType>(node1) <<
" ]"
1461 ss <<
"f(" << node0Origin
1462 <<
")=" << tree1->
getValue<dataType>(node0Origin) <<
" _ ";
1463 ss <<
"g(" << node1Origin
1464 <<
")=" << tree2->
getValue<dataType>(node1Origin) <<
" ] ";
1470 ss <<
"cost = " << tempCost <<
" (" << tempCost2 <<
")" << std::endl;
1474 tree1Done[node0] =
true;
1475 tree2Done[node1] =
true;
1479 if(not tree1Done[i] and not tree1->
isNodeAlone(i)) {
1481 ss <<
"T1 " << i <<
" _ [ f(" << i
1482 <<
") = " << tree1->
getValue<dataType>(i);
1483 ss <<
"_ f(" << nodeOrigin
1484 <<
") = " << tree1->
getValue<dataType>(nodeOrigin);
1488 ss <<
" _ cost = " << tempCost << std::endl;
1494 if(not tree2Done[i] and not tree2->
isNodeAlone(i)) {
1496 ss <<
"T2 " << i <<
" _ [ g(" << i
1497 <<
") = " << tree2->
getValue<dataType>(i);
1498 ss <<
"_ g(" << nodeOrigin
1499 <<
") = " << tree2->
getValue<dataType>(nodeOrigin);
1503 ss <<
" _ cost = " << tempCost << std::endl;
1509 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 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 setPersistenceThreshold(double pt)
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, bool removeMergedSaddles=false)
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_
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, bool removeMergedSaddles=false)
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)