00001 #ifndef _DPSPANNINGTREE 00002 #define _DPSPANNINGTREE 00003 00004 #include <stdio.h> 00005 #include <malloc.h> 00006 #include "eg_macros.h" 00007 #include "eg_mempool.h" 00008 00009 #define SWAP(x,y,temp) {temp = x; x = y; y = temp;} 00010 00011 typedef struct DPspanningNode 00012 { 00013 struct 00014 { 00015 struct DPspanningNode *parent; 00016 int rank; 00017 } 00018 setinfo; 00019 } 00020 DPspanningNode; 00021 00022 typedef struct DPspanningEdge 00023 { 00024 double weight; 00025 int ends[2]; 00026 } 00027 DPspanningEdge; 00028 00029 typedef struct DPedgeSet 00030 { 00031 int nedges; 00032 int *edges; 00033 } 00034 DPedgeSet_t; 00035 00036 void makeset (DPspanningNode * v); 00037 DPspanningNode *find (DPspanningNode * v); 00038 DPspanningNode *slink (DPspanningNode * x, 00039 DPspanningNode * y); 00040 int getprob (char *fname, 00041 int *p_ncount, 00042 int *p_ecount, 00043 int **p_elist, 00044 double **p_wlist); 00045 int kruskal_spanningtree (int ncount, 00046 int ecount, 00047 int *elist, 00048 double *wlist, 00049 int *tlist, 00050 void *function_data); 00051 int biased_spanningtree (int ncount, 00052 int ecount, 00053 int *elist, 00054 double *wlist, 00055 int *tlist, 00056 void *function_data); 00057 void printtree (int ncount, 00058 int *elist, 00059 int *tlist); 00060 void qsort_DPspanningEdges (int *perm, 00061 DPspanningEdge * elist, 00062 int l, 00063 int u); 00064 int buildgraph (int ecount, 00065 int *elist, 00066 double *wlist, 00067 DPspanningEdge ** p_edglist); 00068 00069 #endif