Debian Codegraph @

SYMPHONY/Applications/CNRP/src/DrawGraph/cnrp_dg.c

raw
1 /*===========================================================================*/
2 /* */
3 /* This file is part of a demonstration application for use with the */
4 /* SYMPHONY Branch, Cut, and Price Library. This application is a solver for */
5 /* Capacitated Network Routing Problems. */
6 /* */
7 /* (c) Copyright 2000-2007 Ted Ralphs. All Rights Reserved. */
8 /* */
9 /* This application was developed by Ted Ralphs ([email protected]) */
10 /* */
11 /* This software is licensed under the Eclipse Public License. Please see */
12 /* accompanying file for terms. */
13 /* */
14 /*===========================================================================*/
15
16 /* system include files */
17 #include <stdio.h>
18 #include <math.h>
19
20 /* SYMPHONY include files */
21 #include "sym_constants.h"
22 #include "sym_macros.h"
23 #include "sym_proccomm.h"
24
25 /* CNRP include files */
26 #include "cnrp_dg.h"
27 #include "cnrp_const.h"
28 #include "cnrp_macros.h"
29 #include "cnrp_messages.h"
30
31 /*===========================================================================*/
32
33 /*===========================================================================*\
34 * This file contains the user-written functions for the drawgraph process.
35 \*===========================================================================*/
36
37 int user_dg_process_message(void *user, window *win, FILE *write_to)
38 {
39 cnrp_dg *win_cnrp = (cnrp_dg *)user;
40 int msgtag;
41 int length;
42 int *xind;
43 double *xval;
44
45 receive_int_array(&msgtag, 1);
46 switch (msgtag){
47 case CNRP_CTOI_DRAW_FRAC_GRAPH:
48 receive_int_array(&length, 1);
49 xind = (int *) malloc(length * ISIZE);
50 xval = (double *) malloc(length * DSIZE);
51 receive_int_array(xind, length);
52 receive_dbl_array(xval, length);
53 dg_freenet(win_cnrp->n);
54 win_cnrp->n = dg_createnet(win->g.nodenum, length, xind, xval);
55 FREE(xind);
56 FREE(xval);
57 dg_net_shrink_chains(win_cnrp->n);
58 copy_network_into_graph(win_cnrp->n, &win->g);
59 display_graph_on_canvas(win, write_to);
60 break;
61 }
62 return(USER_SUCCESS);
63 }
64
65 /*===========================================================================*/
66
67 int user_dg_init_window(void **user, window *win)
68 {
69 cnrp_dg *win_cnrp = calloc(1, sizeof(cnrp_dg));
70 #if 0
71 int vertnum = win_cnrp->g.nodenum;
72
73 win_cnrp->edges = (int *) calloc (vertnum*(vertnum-1), sizeof(int));
74
75 /*create the edge list (we assume a complete graph)*/
76 for (i = 1, k = 0; i < vertnum; i++){
77 for (j = 0; j < i; j++){
78 cnrp->edges[2*k] = j;
79 cnrp->edges[2*k+1] = i;
80 k++;
81 }
82 }
83 #endif
84
85 *user = win_cnrp;
86
87 return(USER_SUCCESS);
88 }
89
90 /*===========================================================================*/
91
92 int user_dg_free_window(void **user, window *win)
93 {
94 cnrp_dg *win_cnrp = (cnrp_dg *)*user;
95
96 dg_freenet(win_cnrp->n);
97 FREE(*user);
98
99 return(USER_SUCCESS);
100 }
101
102 /*===========================================================================*/
103
104 int user_initialize_dg(void **user)
105 {
106 return(USER_SUCCESS);
107 }
108
109 /*===========================================================================*/
110
111 int user_free_dg(void **user)
112 {
113 return(USER_SUCCESS);
114 }
115
116 /*===========================================================================*/
117
118 int user_interpret_text(void *user, int text_length, char *text,
119 int owner_tid)
120 {
121 return(USER_SUCCESS);
122 }
123