src/common/tree_decomp.h

00001 
00002 /*
00003 
00004 This tree decomposition based library was written by 
00005 Kyle Ellrott (kellrott@csbl.bmb.uga.edu)
00006 and is distributed under the GPL v2.0 license
00007 
00008 */
00009 
00010 #ifndef __td_decomp_h__
00011 #define __td_decomp_h__
00012 
00013 
00014 typedef struct td_graph {
00015         long vertex_count, edge_count;
00016         long *state_count;
00017         double **vertex_score, ***edge_score;
00018         char **matrix;
00019 } td_graph;
00020 
00021 typedef struct td_decomp {
00022         td_graph *graph;
00023         long bag_count;
00024         long *bag_size;
00025         long **bag;
00026         char **bag_matrix;
00027         long root;
00028 } td_decomp;
00029 
00030 
00031 char **td_matrix_init( long vertex_count );
00032 td_graph * td_graph_init( long vertex_count, long *state_count, char **matrix );
00033 
00034 void td_matrix_free( char ** graph);
00035 void td_graph_free( td_graph *graph);
00036 
00037 
00038 td_decomp * td_graph_decomp_tri( td_graph *graph );
00039 
00040 long *td_graph_decomp_solve( td_decomp *decomp  );
00041 
00042 
00043 inline double td_edge_get( td_graph *graph, long vertex_1, long vertex_2, long state_1, long state_2 ) {
00044         if (vertex_2 > vertex_1) {
00045                 return graph->edge_score[ vertex_1 * graph->vertex_count + vertex_2 ][ state_1 ][ state_2 ];            
00046         }
00047         return graph->edge_score[ vertex_2 * graph->vertex_count + vertex_1 ][ state_2 ][ state_1 ];            
00048 }
00049 
00050 inline void td_edge_set( td_graph *graph, long vertex_1, long vertex_2, long state_1, long state_2, double val ) {
00051         if (vertex_2 > vertex_1) {
00052                 graph->edge_score[ vertex_1 * graph->vertex_count + vertex_2 ][ state_1 ][ state_2 ] = val;             
00053         } else {
00054                 graph->edge_score[ vertex_2 * graph->vertex_count + vertex_1 ][ state_2 ][ state_1 ] = val;             
00055         }
00056 }
00057 
00058 inline long td_edge_offset( td_graph *graph, long vertex_1, long vertex_2) {
00059         return vertex_1 * graph->vertex_count + vertex_2;
00060 }
00061 
00062 
00063 
00064 
00065 #endif

Generated on Wed Apr 11 16:50:50 2007 for open_prospect by  doxygen 1.4.6