/* This file implements a bipartition structure. Copyright (C) 2004 The University of Texas at Austin Based upon Daniel Huson's implementation. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. Email: usman@cs.njit.edu Mail: Usman Roshan, Department of Computer Sciences, NJIT-CCS, Computer Science Department, GITC 4400, University Heights, Newark, NJ 07102 */ #include #include #include #include split new_split() { split s; s = (split) malloc(sizeof(struct split_struct)); s->A = new_int_set(32); s->B = new_int_set(32); return s; } void del_split(split s) { assert(s); assert(s->A); assert(s->B); del_int_set(s->A); del_int_set(s->B); s->A = NULL; s->B = NULL; free(s); } int_set get_A_split(split s) { assert(s); return s->A; } int_set get_B_split(split s) { assert(s); return s->B; } void set_split(split s, int_set A, int_set B, double wgt) { assert(s); if (choose_int_set(A) <= choose_int_set(B)) { assign_int_set(s->A, A); assign_int_set(s->B, B); /* s->A=A; */ } else { assign_int_set(s->A, B); assign_int_set(s->B, A); /* s->A=B; */ } s->wgt = wgt; } void print_split(split s) { assert(s); print_int_set(s->A); printf(": "); printf("%.2f", s->wgt); } void print_split3(split s, int_set taxa) { assert(s); print_int_set(s->A); printf(" | "); print_int_set(s->B); printf(": "); printf("%.2f", s->wgt); }