From 4eabf5d72c6b01bbf11180280ef9d28d5fe587bf Mon Sep 17 00:00:00 2001 From: Nicholas Noll Date: Tue, 28 Apr 2020 11:59:59 -0700 Subject: feat: added number of nodes & leafs to tree data structure --- include/libbio.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'include/libbio.h') diff --git a/include/libbio.h b/include/libbio.h index 0bda4d7..4b92587 100644 --- a/include/libbio.h +++ b/include/libbio.h @@ -12,21 +12,27 @@ typedef struct bio·Node int nchild; int ndescendent; struct bio·Node *parent; + // NOTE: Sibiling allows for polytomies struct bio·Node *child[2]; struct bio·Node *sibling; } bio·Node; -error phylo·addchild(bio·Node *parent, bio·Node* child); -bool phylo·isleaf(bio·Node *node); - typedef struct bio·Tree { bio·Node *root; + int nleaf; + int nnode; } bio·Tree; +// clade functions +error phylo·addchild(bio·Node* parent, bio·Node* child); + +error phylo·countnodes(bio·Node *node, int *n); +error phylo·countleafs(bio·Node *node, int *n); + /* newick i/o */ -bio·Tree bio·readnewick(io·Peeker stream, void*, mem·Allocator heap, void*); -error bio·writenewick(bio·Tree tree, io·Putter out, void*); +error bio·readnewick(io·Peeker stream, void*, mem·Allocator heap, void*, bio·Tree* tree); +error bio·writenewick(bio·Tree tree, io·Putter out, void*); // ----------------------------------------------------------------------- // Sequences -- cgit v1.2.1