blob: 374cd085ad8b68e008b349d63c399629265a331b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
#include <u.h>
#include <libn.h>
#include <libbio.h>
error
phylo·addchild(bio·Node* parent, bio·Node* child)
{
bio·Node *it, *sibling;
switch (parent->nchild) {
case 1:
parent->child[0]->sibling = child;
case 0:
parent->child[parent->nchild++] = child;
break;
default:
sibling = parent->child[1];
for (it = parent->child[1]->sibling; it != nil; it = it->sibling) {
sibling = it;
}
sibling->sibling = child;
parent->nchild++;
}
child->parent = parent;
return 0;
}
|