X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Freorder_phylo.c;fp=src%2Freorder_phylo.c;h=979b23e3e31233a69b47cb182ee08093652dbc6b;hb=eccd02caa284c933ccabf54c2b52d2c871cbd8e8;hp=c54ea52ee9103d28eef2ca301903503dca327e04;hpb=60df2f5f6de3e33d17489ebc271b585375a42303;p=ape.git diff --git a/src/reorder_phylo.c b/src/reorder_phylo.c index c54ea52..979b23e 100644 --- a/src/reorder_phylo.c +++ b/src/reorder_phylo.c @@ -1,12 +1,11 @@ -/* reorder_phylo.c 2008-03-17 */ +/* reorder_phylo.c 2012-08-01 */ -/* Copyright 2008 Emmanuel Paradis */ +/* Copyright 2008-2012 Emmanuel Paradis */ /* This file is part of the R-package `ape'. */ /* See the file ../COPYING for licensing issues. */ #include -#include void neworder_cladewise(int *n, int *edge1, int *edge2, int *N, int *neworder) @@ -61,23 +60,19 @@ void neworder_cladewise(int *n, int *edge1, int *edge2, void neworder_pruningwise(int *ntip, int *nnode, int *edge1, int *edge2, int *nedge, int *neworder) { - int *Ndegr, degree, *ready, rdy, i, j, node, nextI, n; - Ndegr = °ree; - ready = &rdy; + int *ready, *Ndegr, i, j, node, nextI, n; - ready = (int*)R_alloc(*nedge, sizeof(int)); - - /* use `nextI' temporarily because need an address for R_tabulate */ nextI = *ntip + *nnode; Ndegr = (int*)R_alloc(nextI, sizeof(int)); memset(Ndegr, 0, nextI*sizeof(int)); - R_tabulate(edge1, nedge, &nextI, Ndegr); + for (i = 0; i < *nedge; i++) (Ndegr[edge1[i] - 1])++; + + ready = (int*)R_alloc(*nedge, sizeof(int)); /* `ready' indicates whether an edge is ready to be */ /* collected; only the terminal edges are initially ready */ for (i = 0; i < *nedge; i++) - if (edge2[i] <= *ntip) ready[i] = 1; - else ready[i] = 0; + ready[i] = (edge2[i] <= *ntip) ? 1 : 0; /* `n' counts the number of times a node has been seen. */ /* This algo will work if the tree is in cladewise order, */