X-Git-Url: https://git.donarmstrong.com/?a=blobdiff_plain;f=src%2Fbipartition.c;h=d29d554a58386c0ec0d0911b91540d208b99c5c1;hb=2014b83971be4b9cd1644d6127837df798e9335c;hp=a2b34d38d39159fbb1ca705c8701b17f8040d899;hpb=6ee9e0a4e1e6bbc09187382bfdef57fafe3844c7;p=ape.git diff --git a/src/bipartition.c b/src/bipartition.c index a2b34d3..d29d554 100644 --- a/src/bipartition.c +++ b/src/bipartition.c @@ -1,6 +1,6 @@ -/* bipartition.c 2011-06-23 */ +/* bipartition.c 2012-03-26 */ -/* Copyright 2005-2011 Emmanuel Paradis, and 2007 R Development Core Team */ +/* Copyright 2005-2012 Emmanuel Paradis, and 2007 R Development Core Team */ /* This file is part of the R-package `ape'. */ /* See the file ../COPYING for licensing issues. */ @@ -160,8 +160,8 @@ SEXP prop_part(SEXP TREES, SEXP nbtree, SEXP keep_partitions) INTEGER(nbtip)[0] = Ntip; INTEGER(nbnode)[0] = Nnode; - if (KeepPartition) Npart = Ntree*(Nnode - 1) + 1; - else Npart = Nnode; + if (KeepPartition) Npart = Ntree * (Ntip - 2) + 1; + else Npart = Ntip - 1; PROTECT(number = allocVector(INTSXP, Npart)); no = INTEGER(number); /* copy the pointer */ @@ -189,6 +189,11 @@ SEXP prop_part(SEXP TREES, SEXP nbtree, SEXP keep_partitions) /* We start on the 2nd tree: */ for (k = 1; k < Ntree; k++) { + +/* in case there are trees with multichotomies: */ + nbnode = getListElement(VECTOR_ELT(TREES, k), "Nnode"); + Nnode = INTEGER(nbnode)[0]; + PROTECT(bp = bipartition(getListElement(VECTOR_ELT(TREES, k), "edge"), nbtip, nbnode)); for (i = 1; i < Nnode; i++) {