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) {
128 treeLeaves.push_back(i);
133 std::vector<idNode> leaves;
135 return leaves.size();
150 idNode node, std::tuple<std::vector<idNode>, std::vector<idNode>> &res) {
151 std::vector<idNode> branchOrigins, nonBranchOrigins;
155 while(nodeParent != node) {
157 branchOrigins.push_back(nodeParent);
159 nonBranchOrigins.push_back(nodeParent);
163 res = std::make_tuple(branchOrigins, nonBranchOrigins);
167 std::vector<idNode> &branching,
168 std::vector<int> &branchingID,
169 std::vector<std::vector<idNode>> &nodeBranching) {
175 std::queue<idNode> queue;
176 queue.emplace(this->
getRoot());
177 while(!queue.empty()) {
178 idNode const node = queue.front();
183 idNode parentNodeOrigin = nodeOrigin;
184 while(parentNodeOrigin != node) {
185 branching[parentNodeOrigin] = node;
186 branchingID[parentNodeOrigin] = branchID;
187 nodeBranching[node].push_back(parentNodeOrigin);
191 branching[node] = node;
192 branchingID[node] = branchID;
195 std::vector<idNode> children;
197 for(
idNode const child : children)
198 queue.emplace(child);
203 std::vector<int> &branchingID) {
204 std::vector<std::vector<idNode>> nodeBranching;
212 roots.push_back(node);
229 std::queue<std::tuple<idNode, int>> queue;
230 queue.emplace(this->
getRoot(), 0);
231 while(!queue.empty()) {
232 auto tup = queue.front();
234 idNode const node = std::get<0>(tup);
235 int const depth = std::get<1>(tup);
236 maxDepth = std::max(maxDepth, depth);
237 std::vector<idNode> children;
239 for(
idNode const child : children)
240 queue.emplace(child, depth + 1);
250 std::stringstream ss;
251 ss <<
"problem, there is " << noRoot <<
" root(s)";
257 while(nodeId != root) {
266 std::queue<std::tuple<idNode, int>> queue;
267 queue.emplace(this->
getRoot(), 0);
268 while(!queue.empty()) {
269 auto tup = queue.front();
271 idNode const node = std::get<0>(tup);
272 int const level = std::get<1>(tup);
273 allNodeLevel[node] = level;
274 std::vector<idNode> children;
276 for(
idNode const child : children)
277 queue.emplace(child, level + 1);
282 std::vector<std::vector<idNode>> &levelToNode) {
283 std::vector<int> allNodeLevel;
286 = *max_element(allNodeLevel.begin(), allNodeLevel.end());
287 levelToNode = std::vector<std::vector<idNode>>(maxLevel + 1);
288 for(
unsigned int i = 0; i < allNodeLevel.size(); ++i) {
289 levelToNode[allNodeLevel[i]].push_back(i);
295 std::vector<idNode> &branchSubtree) {
296 branchSubtree.clear();
297 std::queue<idNode> queue;
298 queue.push(branchRoot);
299 while(!queue.empty()) {
300 idNode const node = queue.front();
303 if(branching[node] != branchRoot
304 and this->
getParentSafe(node) == branchRoot and node != branchRoot)
307 branchSubtree.push_back(node);
308 std::vector<idNode> children;
310 for(
idNode const child : children)
319 std::vector<std::vector<idNode>> &treeMultiPers) {
347 if(!this->
isRoot(nodeId)) {
378 if(!this->
isRoot(nodeId)) {
385 std::queue<idNode> queue;
387 while(!queue.empty()) {
388 idNode const node = queue.front();
390 std::vector<idNode> children;
392 for(
idNode const child : children)
410 for(
unsigned int j = 0;
411 j < tree->
getNode(i)->getNumberOfDownSuperArcs(); ++j) {
422 ss <<
"(" << node <<
") \\ ";
424 std::vector<idNode> children;
426 for(
idNode const child : children)
427 ss <<
"+" << child <<
" ";
435 std::stringstream ss;
436 ss <<
"Nodes----------" << std::endl;
437 std::queue<idNode> queue;
439 while(!queue.empty()) {
440 idNode node = queue.front();
445 std::vector<idNode> children;
447 for(
idNode child : children)
454 std::stringstream ss;
455 std::vector<idNode> allRoots;
457 if(allRoots.size() != 1)
458 ss << allRoots.size() <<
" roots" << std::endl;
459 for(
unsigned int i = 0; i < allRoots.size(); ++i) {
460 if(allRoots.size() != 1)
464 if(allRoots.size() == 0)
477 std::stringstream ss;
478 ss <<
"tree [node: " << noNodes <<
" / " << noNodesT;
487 std::stringstream ss;
488 std::vector<std::vector<idNode>> vec;
490 for(
unsigned int i = 0; i < vec.size(); ++i)
491 if(vec[i].size() != 0) {
516 ftm::idNode lowestParent = std::numeric_limits<ftm::idNode>::max();
517 for(
long unsigned int j = 0;
518 j < tree->
getNode(i)->getNumberOfUpSuperArcs(); ++j) {
522 lowestParent = (lowestParent > tParent) ? tParent : lowestParent;
525 for(
long unsigned int j = 0;
526 j < tree->
getNode(i)->getNumberOfUpSuperArcs(); ++j) {
530 if(tParent != lowestParent) {
532 if(tParent == treeRoot) {
533 for(
long unsigned int k = 0;
534 k < tree->
getNode(i)->getNumberOfDownSuperArcs(); ++k) {
559 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
bool notNeedToNormalize(idNode nodeId)
void getLevelToNode(std::vector< std::vector< idNode > > &res)
bool isNodeIdInconsistent(idNode nodeId)
SuperArc * getSuperArc(idSuperArc i)
idNode getNumberOfNodes() const
void setParent(idNode nodeId, idNode newParentNodeId)
bool isNodeMerged(idNode nodeId)
int getNumberOfChildren(idNode nodeId)
idNode getDownNodeId(const SuperArc *a)
std::stringstream printMultiPersOriginsVectorFromTree(bool doPrint=true)
void getTreeBranching(std::vector< idNode > &branching, std::vector< int > &branchingID, std::vector< std::vector< idNode > > &nodeBranching)
bool isRoot(idNode nodeId)
void getMultiPersOriginsVectorFromTree(std::vector< std::vector< idNode > > &res)
std::stringstream printSubTree(idNode subRoot)
idNode getParentSafe(idNode nodeId)
void getBranchSubtree(std::vector< idNode > &branching, idNode branchRoot, std::vector< idNode > &res)
bool isNodeOriginDefined(idNode nodeId)
void printNodeSS(idNode node, std::stringstream &ss)
void deleteIthUpArc(idNode nodeId, int arcIth)
int getNodeLevel(idNode nodeId)
void getAllRoots(std::vector< idNode > &res)
int getNumberOfLeavesFromTree()
void getChildren(idNode nodeId, std::vector< idNode > &res)
void deleteNode(idNode nodeId)
bool isMultiPersPair(idNode nodeId)
idNode makeNode(SimplexId vertexId, SimplexId linked=nullVertex)
int getNumberOfNodeAlone()
bool isLeaf(idNode nodeId)
int getRealNumberOfNodes()
void deleteParent(idNode nodeId)
bool isNodeAlone(idNode nodeId)
idSuperArc makeSuperArc(idNode downNodeId, idNode upNodeId)
bool isBranchOrigin(idNode nodeId)
void copyMergeTreeStructure(FTMTree_MT *tree)
void getBranchOriginsFromThisBranch(idNode node, std::tuple< std::vector< idNode >, std::vector< idNode > > &res)
void getLeavesFromTree(std::vector< idNode > &res)
Node * getNode(idNode nodeId)
void getAllNodeLevel(std::vector< int > &res)
std::stringstream printTree(bool doPrint=true)
void deleteSubtree(idNode nodeId)
bool isThereOnlyOnePersistencePair()
std::stringstream printTreeStats(bool doPrint=true)
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)
printMsg(debug::output::BOLD+" | | | | | . \\ | | (__| | / __/| |_| / __/|__ _|"+debug::output::ENDCOLOR, debug::Priority::PERFORMANCE, debug::LineMode::NEW, stream)