TTK
Loading...
Searching...
No Matches
MergeTreeAxesAlgorithmUtils.h
Go to the documentation of this file.
1#pragma once
2
3#include <FTMTree_MT.h>
4#include <string>
5
6namespace ttk {
7 namespace axa {
8 //----------------------------------------------------------------------------
9 // Utils
10 //----------------------------------------------------------------------------
11 // v[i] contains the node in tree matched to the node i in barycenter
12 template <class dataType>
14 const ftm::MergeTree<dataType> &barycenter,
15 const ftm::MergeTree<dataType> &tree,
16 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> &matchings,
17 std::vector<ftm::idNode> &matchingVector) {
18 matchingVector.clear();
19 matchingVector.resize(barycenter.tree.getNumberOfNodes(),
20 std::numeric_limits<ftm::idNode>::max());
21 for(unsigned int j = 0; j < matchings.size(); ++j) {
22 auto &match0 = std::get<0>(matchings[j]);
23 auto &match1 = std::get<1>(matchings[j]);
24 if(match0 < barycenter.tree.getNumberOfNodes()
25 and match1 < tree.tree.getNumberOfNodes())
26 matchingVector[match0] = match1;
27 }
28 }
29
30 // v[i] contains the node in barycenter matched to the node i in tree
31 template <class dataType>
33 const ftm::MergeTree<dataType> &barycenter,
34 const ftm::MergeTree<dataType> &tree,
35 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> &matchings,
36 std::vector<ftm::idNode> &matchingVector) {
37 std::vector<std::tuple<ftm::idNode, ftm::idNode, double>> invMatchings(
38 matchings.size());
39 for(unsigned int i = 0; i < matchings.size(); ++i)
40 invMatchings[i] = std::make_tuple(std::get<1>(matchings[i]),
41 std::get<0>(matchings[i]),
42 std::get<2>(matchings[i]));
43 getMatchingVector(tree, barycenter, invMatchings, matchingVector);
44 }
45
46 void reverseMatchingVector(unsigned int noNodes,
47 std::vector<ftm::idNode> &matchingVector,
48 std::vector<ftm::idNode> &invMatchingVector);
49
50 template <class dataType>
52 std::vector<ftm::idNode> &matchingVector,
53 std::vector<ftm::idNode> &invMatchingVector) {
55 tree.tree.getNumberOfNodes(), matchingVector, invMatchingVector);
56 }
57
58 // m[i][j] contains the node in trees[j] matched to the node i in the
59 // barycenter
60 template <class dataType>
62 const ftm::MergeTree<dataType> &barycenter,
63 std::vector<ftm::MergeTree<dataType>> &trees,
64 std::vector<std::vector<std::tuple<ftm::idNode, ftm::idNode, double>>>
65 &matchings,
66 std::vector<std::vector<ftm::idNode>> &matchingMatrix) {
67 matchingMatrix.clear();
68 matchingMatrix.resize(
69 barycenter.tree.getNumberOfNodes(),
70 std::vector<ftm::idNode>(
71 trees.size(), std::numeric_limits<ftm::idNode>::max()));
72 for(unsigned int i = 0; i < trees.size(); ++i) {
73 std::vector<ftm::idNode> matchingVector;
75 barycenter, trees[i], matchings[i], matchingVector);
76 for(unsigned int j = 0; j < matchingVector.size(); ++j)
77 matchingMatrix[j][i] = matchingVector[j];
78 }
79 }
80
81 //----------------------------------------------------------------------------
82 // Output Utils
83 //----------------------------------------------------------------------------
84 void zeroPadding(std::string &colName,
85 const size_t numberCols,
86 const size_t colIdx);
87
88 std::string getTableCoefficientName(int noAxes, int axeNum);
89
90 std::string getTableCoefficientNormName(int noAxes, int axeNum);
91
92 std::string getTableVectorName(
93 int noAxes, int axeNum, int vId, int vComp, bool isSecondInput = false);
94
95 std::string getTableCorrelationName(int noAxes, int axeNum);
96
97 std::string getTableCorrelationPersName(int noAxes, int axeNum);
98
99 std::string getTableTreeName(int noTrees, int treeNum);
100 } // namespace axa
101} // namespace ttk
idNode getNumberOfNodes() const
Definition FTMTree_MT.h:389
void getMatchingMatrix(const 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 zeroPadding(std::string &colName, const size_t numberCols, const size_t colIdx)
std::string getTableCoefficientNormName(int noAxes, int axeNum)
std::string getTableCorrelationPersName(int noAxes, int axeNum)
void reverseMatchingVector(unsigned int noNodes, std::vector< ftm::idNode > &matchingVector, std::vector< ftm::idNode > &invMatchingVector)
std::string getTableVectorName(int noAxes, int axeNum, int vId, int vComp, bool isSecondInput)
std::string getTableTreeName(int noTrees, int treeNum)
void getMatchingVector(const ftm::MergeTree< dataType > &barycenter, const ftm::MergeTree< dataType > &tree, std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > &matchings, std::vector< ftm::idNode > &matchingVector)
void getInverseMatchingVector(const ftm::MergeTree< dataType > &barycenter, const ftm::MergeTree< dataType > &tree, std::vector< std::tuple< ftm::idNode, ftm::idNode, double > > &matchings, std::vector< ftm::idNode > &matchingVector)
std::string getTableCoefficientName(int noAxes, int axeNum)
std::string getTableCorrelationName(int noAxes, int axeNum)
TTK base package defining the standard types.
ftm::FTMTree_MT tree
Definition FTMTree_MT.h:906