diff --git a/phylogeny/distTree.cpp b/phylogeny/distTree.cpp index d63799bd..1c0d2fb3 100644 --- a/phylogeny/distTree.cpp +++ b/phylogeny/distTree.cpp @@ -3142,7 +3142,8 @@ DistTree::DistTree (const string &treeFName, if (! getConnected ()) throw runtime_error (FUNC "Disconnected objects"); - setDiscernibles_ds (); + if (! setDiscernibles_ds ()) + return; if (isDirName (treeFName)) setGlobalLen (); // --> after dissim2Ds(), use dissims ?? @@ -3173,7 +3174,8 @@ DistTree::DistTree (const string &dissimFName, if (! getConnected ()) throw runtime_error (FUNC "Disconnected objects"); - setDiscernibles_ds (); + if (! setDiscernibles_ds ()) + return; neighborJoin (); @@ -3972,8 +3974,6 @@ DistTree::DistTree (Subgraph &subgraph, setPaths (false); -//ASSERT (setDiscernibles_ds () == 0); - qcPaths (); } @@ -4511,7 +4511,7 @@ Cluster2Leaves DistTree::getIndiscernibles () -size_t DistTree::leafCluster2discernibles (const Cluster2Leaves &cluster2leaves) +void DistTree::leafCluster2discernibles (const Cluster2Leaves &cluster2leaves) { ASSERT (! subDepth); @@ -4574,13 +4574,11 @@ size_t DistTree::leafCluster2discernibles (const Cluster2Leaves &cluster2leaves) if (n) cleanTopology (); - - return n; } -size_t DistTree::setDiscernibles_ds () +bool DistTree::setDiscernibles_ds () { ASSERT (! subDepth); ASSERT (dissimDs. get ()); @@ -4599,9 +4597,6 @@ size_t DistTree::setDiscernibles_ds () } } -//if (DistTree_sp::variance_min) - //return 0; - FFOR (size_t, row, dissimDs->objs. size ()) if (const Leaf* leaf1 = findPtr (name2leaf, dissimDs->objs [row] -> name)) FOR (size_t, col, row) // dissimAttr is symmetric @@ -4616,16 +4611,16 @@ size_t DistTree::setDiscernibles_ds () if (const Leaf* leaf = dtNode->asLeaf ()) cluster2leaves [var_cast (leaf) -> getDisjointCluster ()] << leaf; } + ASSERT (! cluster2leaves. empty ()); - if (cluster2leaves. size () == 1) - throw runtime_error (FUNC "No discernible objects"); - - return leafCluster2discernibles (cluster2leaves); + leafCluster2discernibles (cluster2leaves); + + return cluster2leaves. size () > 1; } -size_t DistTree::setDiscernibles () +void DistTree::setDiscernibles () { ASSERT (! subDepth); ASSERT (optimizable ()); @@ -4641,11 +4636,9 @@ size_t DistTree::setDiscernibles () //return 0; const Cluster2Leaves cluster2leaves (getIndiscernibles ()); - const size_t n = leafCluster2discernibles (cluster2leaves); + leafCluster2discernibles (cluster2leaves); qcPaths (); - - return n; } diff --git a/phylogeny/distTree.hpp b/phylogeny/distTree.hpp index 9818f4e0..8b173ad9 100644 --- a/phylogeny/distTree.hpp +++ b/phylogeny/distTree.hpp @@ -1262,12 +1262,13 @@ struct DistTree : Tree // Return: VectorPtr::size() >= 2 // Invokes: Leaf->DisjointCluster // Time: ~ O(p) - size_t leafCluster2discernibles (const Cluster2Leaves &cluster2leaves); + void leafCluster2discernibles (const Cluster2Leaves &cluster2leaves); // Return: Number of indiscernible leaves // Output: Leaf::len = 0, Leaf::discernible = false, topology // Invokes: cleanTopology() // Time: O(n) - size_t setDiscernibles_ds (); + bool setDiscernibles_ds (); + // Return: success // Invokes: leafCluster2discernibles() void cleanTopology (); // Time: O(n) @@ -1404,7 +1405,7 @@ struct DistTree : Tree // Time: O(p log(n) / threads_max) void qcPredictionAbsCriterion () const; public: - size_t setDiscernibles (); + void setDiscernibles (); // Invokes: getIndiscernibles(), leafCluster2discernibles() size_t fixTransients (); // Return: number of transient nodes deleted diff --git a/phylogeny/makeDistTree.cpp b/phylogeny/makeDistTree.cpp index 14186de1..17a893fc 100644 --- a/phylogeny/makeDistTree.cpp +++ b/phylogeny/makeDistTree.cpp @@ -401,6 +401,12 @@ struct ThisApplication : Application ); } ASSERT (tree. get ()); + if (tree->getDiscernibles (). size () == 1) + { + cout << "One discernible object" << endl; + return; + } + ASSERT (optimizable == tree->optimizable ()); if (variance_dissim) diff --git a/version.inc b/version.inc index 7acaf8b3..96108374 100644 --- a/version.inc +++ b/version.inc @@ -1,6 +1,7 @@ -#define VERSION "1.9.6" +#define VERSION "1.9.7" +// 1.9.7 07/06/2022 there may be 1 indiscernible object // 1.9.6 10/18/2021 distTree_inc_refresh_dissim.sh // 1.9.5 07/23/2021 -prefer_gain is restored in tree2names.sh // 1.9.4 06/09/2021 combine_dissims.cpp: -barrier