7 tree->printTreeStats();
17 unsigned int const origin
58 unsigned int cptNodeAlone = 0;
59 idNode otherNode = treeRoot;
63 else if(i != treeRoot)
68 return (otherNode != treeRoot
70 and (treeRootOrigin == otherNode or treeRootOrigin == treeRoot));
79 return this->
isRoot(nodeId)
80 or (this->
isRoot(nodeIdParent)
82 == (
unsigned int)this->
getNode(nodeIdParent)
91 return nodeOriginOrigin != nodeId;
105 if(!this->
isRoot(nodeId)) {
115 std::vector<idNode> &childrens)
const {
128 treeLeaves.push_back(i);
133 std::vector<idNode> leaves;
135 return leaves.size();
151 std::tuple<std::vector<idNode>, std::vector<idNode>> &res)
const {
152 std::vector<idNode> branchOrigins, nonBranchOrigins;
156 while(nodeParent != node) {
158 branchOrigins.push_back(nodeParent);
160 nonBranchOrigins.push_back(nodeParent);
164 res = std::make_tuple(branchOrigins, nonBranchOrigins);
168 std::vector<idNode> &branching,
169 std::vector<int> &branchingID,
170 std::vector<std::vector<idNode>> &nodeBranching)
const {
176 std::queue<idNode> queue;
177 queue.emplace(this->
getRoot());
178 while(!queue.empty()) {
179 idNode const node = queue.front();
184 idNode parentNodeOrigin = nodeOrigin;
185 while(parentNodeOrigin != node) {
186 branching[parentNodeOrigin] = node;
187 branchingID[parentNodeOrigin] = branchID;
188 nodeBranching[node].push_back(parentNodeOrigin);
192 branching[node] = node;
193 branchingID[node] = branchID;
196 std::vector<idNode> children;
198 for(
idNode const child : children)
199 queue.emplace(child);
204 std::vector<int> &branchingID)
const {
205 std::vector<std::vector<idNode>> nodeBranching;
213 roots.push_back(node);
230 std::queue<std::tuple<idNode, int>> queue;
231 queue.emplace(this->
getRoot(), 0);
232 while(!queue.empty()) {
233 auto tup = queue.front();
235 idNode const node = std::get<0>(tup);
236 int const depth = std::get<1>(tup);
237 maxDepth = std::max(maxDepth, depth);
238 std::vector<idNode> children;
240 for(
idNode const child : children)
241 queue.emplace(child, depth + 1);
251 std::stringstream ss;
252 ss <<
"problem, there is " << noRoot <<
" root(s)";
258 while(nodeId != root) {
267 std::queue<std::tuple<idNode, int>> queue;
268 queue.emplace(this->
getRoot(), 0);
269 while(!queue.empty()) {
270 auto tup = queue.front();
272 idNode const node = std::get<0>(tup);
273 int const level = std::get<1>(tup);
274 allNodeLevel[node] = level;
275 std::vector<idNode> children;
277 for(
idNode const child : children)
278 queue.emplace(child, level + 1);
283 std::vector<std::vector<idNode>> &levelToNode)
const {
284 std::vector<int> allNodeLevel;
287 = *max_element(allNodeLevel.begin(), allNodeLevel.end());
288 levelToNode = std::vector<std::vector<idNode>>(maxLevel + 1);
289 for(
unsigned int i = 0; i < allNodeLevel.size(); ++i) {
290 levelToNode[allNodeLevel[i]].push_back(i);
297 std::vector<idNode> &branchSubtree)
const {
298 branchSubtree.clear();
299 std::queue<idNode> queue;
300 queue.push(branchRoot);
301 while(!queue.empty()) {
302 idNode const node = queue.front();
305 if(branching[node] != branchRoot
306 and this->
getParentSafe(node) == branchRoot and node != branchRoot)
309 branchSubtree.push_back(node);
310 std::vector<idNode> children;
312 for(
idNode const child : children)
321 std::vector<std::vector<idNode>> &treeMultiPers)
const {
349 if(!this->
isRoot(nodeId)) {
380 if(!this->
isRoot(nodeId)) {
387 std::queue<idNode> queue;
389 while(!queue.empty()) {
390 idNode const node = queue.front();
392 std::vector<idNode> children;
394 for(
idNode const child : children)
412 for(
unsigned int j = 0;
413 j < tree->
getNode(i)->getNumberOfDownSuperArcs(); ++j) {
424 ss <<
"(" << node <<
") \\ ";
426 std::vector<idNode> children;
428 for(
idNode const child : children)
429 ss <<
"+" << child <<
" ";
437 std::stringstream ss;
438 ss <<
"Nodes----------" << std::endl;
439 std::queue<idNode> queue;
441 while(!queue.empty()) {
442 idNode node = queue.front();
447 std::vector<idNode> children;
449 for(
idNode child : children)
456 std::stringstream ss;
457 std::vector<idNode> allRoots;
459 if(allRoots.size() != 1)
460 ss << allRoots.size() <<
" roots" << std::endl;
461 for(
unsigned int i = 0; i < allRoots.size(); ++i) {
462 if(allRoots.size() != 1)
466 if(allRoots.size() == 0)
479 std::stringstream ss;
480 ss <<
"tree [node: " << noNodes <<
" / " << noNodesT;
489 std::stringstream ss;
490 std::vector<std::vector<idNode>> vec;
492 for(
unsigned int i = 0; i < vec.size(); ++i)
493 if(vec[i].size() != 0) {
518 ftm::idNode lowestParent = std::numeric_limits<ftm::idNode>::max();
519 for(
long unsigned int j = 0;
520 j < tree->
getNode(i)->getNumberOfUpSuperArcs(); ++j) {
524 lowestParent = (lowestParent > tParent) ? tParent : lowestParent;
527 for(
long unsigned int j = 0;
528 j < tree->
getNode(i)->getNumberOfUpSuperArcs(); ++j) {
532 if(tParent != lowestParent) {
534 if(tParent == treeRoot) {
535 for(
long unsigned int k = 0;
536 k < tree->
getNode(i)->getNumberOfDownSuperArcs(); ++k) {
561 for(
unsigned int j = 0; j < tree->
getNode(i)->getNumberOfUpSuperArcs();
int printErr(const std::string &msg, const debug::LineMode &lineMode=debug::LineMode::NEW, std::ostream &stream=std::cerr) const
std::stringstream printMultiPersOriginsVectorFromTree(bool doPrint=true) const
void getMultiPersOriginsVectorFromTree(std::vector< std::vector< idNode > > &res) const
bool isBranchOrigin(idNode nodeId) const
int getNumberOfLeavesFromTree() const
int getNumberOfNodeAlone() const
Node * getNode(idNode nodeId) const
std::stringstream printTree(bool doPrint=true) const
FTMTree_MT(const std::shared_ptr< Params > ¶ms, const std::shared_ptr< Scalars > &scalars, TreeType type)
void getChildren(idNode nodeId, std::vector< idNode > &res) const
SuperArc * getSuperArc(idSuperArc i)
void getTreeBranching(std::vector< idNode > &branching, std::vector< int > &branchingID, std::vector< std::vector< idNode > > &nodeBranching) const
idNode getNumberOfNodes() const
bool isMultiPersPair(idNode nodeId) const
void setParent(idNode nodeId, idNode newParentNodeId)
void copyMergeTreeStructure(const FTMTree_MT *tree)
idNode getDownNodeId(const SuperArc *a)
std::stringstream printTreeStats(bool doPrint=true) const
int getNodeLevel(idNode nodeId) const
idNode getParentSafe(idNode nodeId) const
void getLevelToNode(std::vector< std::vector< idNode > > &res) const
void getAllNodeLevel(std::vector< int > &res) const
std::stringstream printSubTree(idNode subRoot) const
int getNumberOfChildren(idNode nodeId) const
void deleteIthUpArc(idNode nodeId, int arcIth)
int getRealNumberOfNodes() const
void getLeavesFromTree(std::vector< idNode > &res) const
void getBranchOriginsFromThisBranch(idNode node, std::tuple< std::vector< idNode >, std::vector< idNode > > &res) const
bool isNodeOriginDefined(idNode nodeId) const
bool isLeaf(idNode nodeId) const
void deleteNode(idNode nodeId)
void getAllRoots(std::vector< idNode > &res) const
bool isRoot(idNode nodeId) const
bool notNeedToNormalize(idNode nodeId) const
bool isNodeIdInconsistent(idNode nodeId) const
int getNumberOfRoot() const
idNode makeNode(SimplexId vertexId, SimplexId linked=nullVertex)
bool isNodeAlone(idNode nodeId) const
void deleteParent(idNode nodeId)
bool isNodeMerged(idNode nodeId) const
idSuperArc makeSuperArc(idNode downNodeId, idNode upNodeId)
void printNodeSS(idNode node, std::stringstream &ss) const
void getBranchSubtree(std::vector< idNode > &branching, idNode branchRoot, std::vector< idNode > &res) const
void deleteSubtree(idNode nodeId)
bool isThereOnlyOnePersistencePair() const
idSuperArc getUpSuperArcId(idSuperArc neighborId) const
idSuperArc clearUpSuperArcs()
idSuperArc getNumberOfDownSuperArcs() const
idSuperArc getDownSuperArcId(idSuperArc neighborId) const
void removeUpSuperArc(idSuperArc idSa)
idSuperArc clearDownSuperArcs()
void setOrigin(SimplexId linked)
void removeDownSuperArc(idSuperArc idSa)
SimplexId getOrigin() const
idSuperArc getNumberOfUpSuperArcs() const
idNode getUpNodeId() const
idNode getDownNodeId() const
long unsigned int idSuperArc
SuperArc index in vect_superArcs_.
void removeSelfLink(FTMTree_MT *tree)
void printTreesStats(std::vector< ftm::FTMTree_MT * > &trees)
unsigned int idNode
Node index in vect_nodes_.
void manageInconsistentArcsMultiParent(FTMTree_MT *tree)
TTK base package defining the standard types.
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/| (_) |"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)