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);
134 return leaves.size();
149 idNode node, std::tuple<std::vector<idNode>, std::vector<idNode>> &res) {
150 std::vector<idNode> branchOrigins, nonBranchOrigins;
154 while(nodeParent != node) {
156 branchOrigins.push_back(nodeParent);
158 nonBranchOrigins.push_back(nodeParent);
162 res = std::make_tuple(branchOrigins, nonBranchOrigins);
166 std::vector<idNode> &branching,
167 std::vector<int> &branchingID,
168 std::vector<std::vector<idNode>> &nodeBranching) {
174 std::queue<idNode> queue;
175 queue.emplace(this->
getRoot());
176 while(!queue.empty()) {
177 idNode const node = queue.front();
182 idNode parentNodeOrigin = nodeOrigin;
183 while(parentNodeOrigin != node) {
184 branching[parentNodeOrigin] = node;
185 branchingID[parentNodeOrigin] = branchID;
186 nodeBranching[node].push_back(parentNodeOrigin);
190 branching[node] = node;
191 branchingID[node] = branchID;
194 std::vector<idNode> children;
196 for(
idNode const child : children)
197 queue.emplace(child);
202 std::vector<int> &branchingID) {
203 std::vector<std::vector<idNode>> nodeBranching;
211 roots.push_back(node);
228 std::queue<std::tuple<idNode, int>> queue;
229 queue.emplace(this->
getRoot(), 0);
230 while(!queue.empty()) {
231 auto tup = queue.front();
233 idNode const node = std::get<0>(tup);
234 int const depth = std::get<1>(tup);
235 maxDepth = std::max(maxDepth, depth);
236 std::vector<idNode> children;
238 for(
idNode const child : children)
239 queue.emplace(child, depth + 1);
249 std::stringstream ss;
250 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 std::vector<idNode> allRoots;
438 if(allRoots.size() != 1)
439 ss << allRoots.size() <<
" roots" << std::endl;
440 for(
unsigned int i = 0; i < allRoots.size(); ++i) {
441 if(allRoots.size() != 1)
443 ss <<
"Nodes----------" << std::endl;
444 std::queue<idNode> queue;
445 queue.push(allRoots[i]);
446 while(!queue.empty()) {
447 idNode const node = queue.front();
452 std::vector<idNode> children;
454 for(
idNode const child : children)
458 if(allRoots.size() == 0)
471 std::stringstream ss;
472 ss <<
"tree [node: " << noNodes <<
" / " << noNodesT;
481 std::stringstream ss;
482 std::vector<std::vector<idNode>> vec;
484 for(
unsigned int i = 0; i < vec.size(); ++i)
485 if(vec[i].size() != 0) {
510 ftm::idNode lowestParent = std::numeric_limits<ftm::idNode>::max();
511 for(
long unsigned int j = 0;
512 j < tree->
getNode(i)->getNumberOfUpSuperArcs(); ++j) {
516 lowestParent = (lowestParent > tParent) ? tParent : lowestParent;
519 for(
long unsigned int j = 0;
520 j < tree->
getNode(i)->getNumberOfUpSuperArcs(); ++j) {
524 if(tParent != lowestParent) {
526 if(tParent == treeRoot) {
527 for(
long unsigned int k = 0;
528 k < tree->
getNode(i)->getNumberOfDownSuperArcs(); ++k) {
553 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)
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)
const std::vector< idNode > & getLeaves() const
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)