alpar@6: /*** netgen.h alpar@6: *** Prototype code for inclusion into network generation routines alpar@6: ***/ alpar@6: alpar@6: /*** Constant definitions */ alpar@6: alpar@6: #ifndef NULL alpar@6: #define NULL 0 alpar@6: #endif alpar@6: alpar@6: #define BAD_SEED -1 /* error indicators */ alpar@6: #define TOO_BIG -2 alpar@6: #define BAD_PARMS -3 alpar@6: #define ALLOCATION_FAILURE -4 alpar@6: alpar@6: alpar@6: /*** Type definitions */ alpar@6: alpar@6: typedef unsigned long NODE; /* node number */ alpar@6: typedef unsigned long ARC; /* arc number */ alpar@6: typedef long CAPACITY; /* arc capacity */ alpar@6: typedef long COST; /* arc cost */ alpar@6: typedef unsigned long INDEX; /* index element */ alpar@6: typedef int INDEX_LIST; /* index list handle */ alpar@6: alpar@6: alpar@6: /*** Function prototypes */ alpar@6: alpar@6: #ifdef __STDC__ alpar@6: alpar@6: #include alpar@6: #include alpar@6: alpar@6: void netgen_(long*, long[], long*, long*); /* Fortran external interface */ alpar@6: ARC netgen(long, long*); /* C external interface */ alpar@6: alpar@6: INDEX_LIST make_index_list(INDEX, INDEX); /* allocates a new index list */ alpar@6: void free_index_list(INDEX_LIST); /* frees an existing list */ alpar@6: INDEX choose_index(INDEX_LIST, INDEX); /* chooses index at specified position */ alpar@6: void remove_index(INDEX_LIST, INDEX); /* removes specified index from list */ alpar@6: INDEX index_size(INDEX_LIST); /* number of indices remaining */ alpar@6: INDEX pseudo_size(INDEX_LIST); /* "modified" index size */ alpar@6: alpar@6: void set_random(long); /* initialize random seed */ alpar@6: long ng_random(long, long); /* generate random integer in interval */ alpar@6: alpar@6: #else alpar@6: alpar@6: void *malloc(); /* some standard header should define this */ alpar@6: void *realloc(); /* ditto */ alpar@6: void free(); /* ditto */ alpar@6: void *memset(); /* ditto */ alpar@6: void exit(); /* ditto */ alpar@6: alpar@6: void netgen_(); /* Fortran external interface */ alpar@6: ARC netgen(); /* C external interface */ alpar@6: alpar@6: INDEX_LIST make_index_list(); /* allocates a new index list */ alpar@6: void free_index_list(); /* frees an existing list */ alpar@6: INDEX choose_index(); /* chooses index at specified position */ alpar@6: void remove_index(); /* removes specified index from list */ alpar@6: INDEX index_size(); /* number of indices remaining */ alpar@6: INDEX pseudo_size(); /* "modified" index size */ alpar@6: alpar@6: void set_random(); /* initialize random seed */ alpar@6: long ng_random(); /* generate random integer in interval */ alpar@6: alpar@6: #endif alpar@6: alpar@6: /*** To maintain compatibility with the old Fortran network generator, alpar@6: *** the following are defined. This allows linking the generator code alpar@6: *** with the solver, with the generated network passed to the solver alpar@6: *** through arrays in memory. alpar@6: ***/ alpar@6: alpar@6: #define MAXNODES 10000000 /* maximum problem sizes */ alpar@6: #define MAXARCS 40000000 alpar@6: alpar@6: #define FROM arrays_ /* aliases for network storage */ alpar@6: #define TO arraye_ alpar@6: #define U arrayu_ alpar@6: #define C arrayc_ alpar@6: #define B arrayb_ alpar@6: alpar@6: #ifdef ALLOCATE_NETWORK /* storage definitions */ alpar@6: #define EXTERN alpar@6: #else alpar@6: #define EXTERN extern alpar@6: #endif alpar@6: alpar@6: EXTERN NODE FROM[MAXARCS]; /* origin of each arc */ alpar@6: EXTERN NODE TO [MAXARCS]; /* destination */ alpar@6: EXTERN CAPACITY U [MAXARCS]; /* capacity */ alpar@6: EXTERN COST C [MAXARCS]; /* cost */ alpar@6: EXTERN CAPACITY B [MAXNODES]; /* supply (demand) at each node */