[Vegan-commits] r2851 - pkg/vegan/R

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Feb 7 10:18:50 CET 2014


Author: jarioksa
Date: 2014-02-07 10:18:50 +0100 (Fri, 07 Feb 2014)
New Revision: 2851

Modified:
   pkg/vegan/R/as.hclust.spantree.R
Log:
rethink hclust tree traversal: it is simple

Modified: pkg/vegan/R/as.hclust.spantree.R
===================================================================
--- pkg/vegan/R/as.hclust.spantree.R	2014-02-06 09:51:23 UTC (rev 2850)
+++ pkg/vegan/R/as.hclust.spantree.R	2014-02-07 09:18:50 UTC (rev 2851)
@@ -67,22 +67,14 @@
     function(merge)
 {
     ## Get order of leaves with recursive search from the root
-    visited <- matrix(FALSE, nrow = nrow(merge), ncol=ncol(merge))
     order <- numeric(nrow(merge)+1)
     ind <- 0
-    ## "<<-" updates data only within this function, but outside the
-    ## visit() function.
+    ## "<<-" updates data only within hclustMergeOrder, but outside
+    ## the visit() function.
     visit <- function(i, j) {
-        if(visited[i,j])
-            return(NULL)
-        else {
-            visited[i,j] <<- TRUE
-        }
         if (merge[i,j] < 0) {
             ind <<- ind+1
             order[ind] <<- -merge[i,j]
-            if (j == 1)
-                visit(i, 2)
         } else {
             visit(merge[i,j], 1)
             visit(merge[i,j], 2)



More information about the Vegan-commits mailing list