3 /* Copyright 2007-2008 Vincent Lefort, modified by Emmanuel Paradis */
5 /* This file is part of the R-package `ape'. */
6 /* See the file ../COPYING for licensing issues. */
28 #ifndef MAX_LABEL_LENGTH
29 #define MAX_LABEL_LENGTH 30
31 #ifndef NODE_LABEL_LENGTH
32 #define NODE_LABEL_LENGTH 30
34 #ifndef EDGE_LABEL_LENGTH
35 #define EDGE_LABEL_LENGTH 30
40 /* #ifndef INPUT_SIZE */
41 /* #define INPUT_SIZE 100 */
43 #ifndef MAX_INPUT_SIZE
44 #define MAX_INPUT_SIZE 100000
47 #define EPSILON 1.E-06
49 #ifndef ReadOpenParenthesis
50 #define ReadOpenParenthesis 0
65 #define XINDEX(i, j) n*(i - 1) - i*(i - 1)/2 + j - i - 1
69 char name[MAX_LABEL_LENGTH];
73 typedef struct pointers
80 char label[NODE_LABEL_LENGTH];
81 struct edge *parentEdge;
82 struct edge *leftEdge;
83 struct edge *middleEdge;
84 struct edge *rightEdge;
90 char label[EDGE_LABEL_LENGTH];
91 struct node *tail; /*for edge (u,v), u is the tail, v is the head*/
93 int bottomsize; /*number of nodes below edge */
94 int topsize; /*number of nodes above edge */
100 char name[MAX_LABEL_LENGTH];
108 struct node *firstNode;
109 struct set *secondNode;
112 void me_b(double *X, int *N, char **labels, int *nni, int *edge1, int *edge2, double *el, char **tl);
113 void me_o(double *X, int *N, char **labels, int *nni, int *edge1, int *edge2, double *el, char **tl);
114 //int whiteSpace(char c);
115 double **initDoubleMatrix(int d);
116 double **loadMatrix (double *X, char **labels, int n, set *S);
117 set *addToSet(node *v, set *X);
118 node *makeNewNode(char *label, int i);
119 node *makeNode(char *label, edge *parentEdge, int index);
120 node *copyNode(node *v);
121 edge *siblingEdge(edge *e);
122 edge *makeEdge(char *label, node *tail, node *head, double weight);
124 void updateSizes(edge *e, int direction);
125 tree *detrifurcate(tree *T);
126 void compareSets(tree *T, set *S);
127 void partitionSizes(tree *T);
128 edge *depthFirstTraverse(tree *T, edge *e);
129 edge *findBottomLeft(edge *e);
130 edge *moveRight(edge *e);
131 edge *topFirstTraverse(tree *T, edge *e);
132 edge *moveUpRight(edge *e);
133 void freeMatrix(double **D, int size);
134 void freeSet(set *S);
135 void freeTree(tree *T);
136 void freeSubTree(edge *e);
137 int whiteSpace(char c);
139 node *decodeNewickSubtree(char *treeString, tree *T, int *uCount);
140 tree *readNewickString (char *str, int numLeaves);
141 void subtree2phylo(node *parent, int *edge1, int *edge2, double *el, char **tl);
142 void tree2phylo(tree *T, int *edge1, int *edge2, double *el, char **tl, int n);