85 printf(
"Usage: min_crossings [opts] file.dot file.ord\n" );
86 printf(
" where opts is one or more of the following\n" );
88 " -h (median | bary | mod_bary | mcn | sifting | mce | mce_s | mse\n" 89 " | static_bary | alt_bary | up_down_bary | rotate_bary | slab_bary {parallel barycenter versions})\n" 90 " [main heuristic - default none]\n" 91 " -p (bfs | dfs | mds) [preprocessing - default none]\n" 92 " -z if post processing (repeated swaps until no improvement) is desired\n" 93 " -i MAX_ITERATIONS [stop if no improvement]\n" 94 " -R SEED edge list, node list, or sequence of layers will be randomized\n" 95 " after each pass of mod_bary, mce, mcn, mse, sifting, etc.\n" 96 " to break ties differently when sorting; SEED is an integer seed\n" 97 " -r SECONDS = maximum runtime [stop if no improvement]\n" 98 " -c ITERATION [capture the order after this iteration in a file]\n" 99 " -P PARETO_OBJECTIVES (b_t | s_t | b_s) pair of objectives for Pareto optima\n" 100 " b = bottleneck, t = total, s = stretch (default = none)\n" 101 " -o BASE produce file(s) with name(s) BASE-h.ord, where h is the heuristic used\n" 102 " -o _ (underscore) means use the base name of the dot file\n" 103 " -w (none | avg | left) [adjust weights in barycenter, default left, but avg in parallel versions]\n" 104 " -b average the averages of the two neighboring layers when computing barycenter weights\n" 105 " [this is the default for parallel versions]\n" 106 " -s (layer | degree | random) [sifting variation - see paper]\n" 107 " -e (nodes | edges | early | one_node )\n" 108 " [mce variation - default is nodes: pass ends when all nodes are marked]\n" 109 " -g (total | max) [what sifting is based on] [default: total for sifting, mcn; max for mce]\n" 110 " [not implemented yet]\n" 111 " -v to get verbose information about the graph\n" 112 " -t trace_freq, if trace printout is desired, 0 means only at the end of a pass, > 0 sets frequency\n" 113 " -f create a special .dot file of 'favored' edges; used for visualizing\n" 114 " -k NUMBER_OF_PROCESSORS (for simulation); currently supports 0 or 1\n" 115 " [0 means unlimited and is default for parallel barycenter versions]\n" 116 " -m number of OpenMP threads [default: 1]\n" 134 char * without_directory = basename( buffer );
135 char * pointer_to_last_period = strrchr( without_directory,
'.' );
136 *pointer_to_last_period =
'\0';
137 return without_directory;
142 printf(
"--- Running preprocessor %s\n",
preprocessor );
155 exit( EXIT_FAILURE );
166 printf(
"=== Running heuristic %s\n",
heuristic );
169 else if( strcmp(
heuristic,
"median" ) == 0 )
171 else if( strcmp(
heuristic,
"bary" ) == 0 )
173 else if( strcmp(
heuristic,
"mod_bary" ) == 0 )
175 else if( strcmp(
heuristic,
"static_bary" ) == 0 ) {
181 else if( strcmp(
heuristic,
"alt_bary" ) == 0 ) {
187 else if( strcmp(
heuristic,
"up_down_bary" ) == 0 ) {
192 else if( strcmp(
heuristic,
"slab_bary" ) == 0 ) {
197 else if( strcmp(
heuristic,
"rotate_bary" ) == 0 ) {
203 else if ( strcmp(
heuristic,
"mcn" ) == 0 )
205 else if ( strcmp(
heuristic,
"mce_s" ) == 0 )
207 else if ( strcmp(
heuristic,
"sifting" ) == 0 )
209 else if( strcmp(
heuristic,
"mce" ) == 0 ) {
212 else if( strcmp(
heuristic,
"mse" ) == 0 ) {
216 printf(
"Bad heuristic '%s'\n",
heuristic );
218 exit( EXIT_FAILURE );
234 int main(
int argc,
char * argv[] )
236 printf(
"################################################################\n");
237 printf(
"########### min_crossings, release 1.1, 2016/05/23 #############\n");
245 while ( (ch = getopt(argc, argv,
"bc:e:fgh:i:k:o:p:P:R:r:s:t:vw:zm:")) != -1)
267 seed = atoi( optarg );
282 printf(
"Bad value '%s' for option -P\n", optarg );
284 exit( EXIT_FAILURE );
298 printf(
"Bad value '%s' for option -w\n", optarg );
300 exit( EXIT_FAILURE );
312 printf(
"Bad value '%s' for option -s\n", optarg );
314 exit( EXIT_FAILURE );
324 printf(
"Bad value '%s' for option -e\n", optarg );
326 exit( EXIT_FAILURE );
333 printf(
"Bad value '%s' for option -g\n", optarg );
335 exit( EXIT_FAILURE );
363 exit( EXIT_FAILURE );
380 printf(
"Wrong number of filenames (%d)\n", argc );
382 exit( EXIT_FAILURE );
384 const char * dot_file_name = argv[0];
385 const char * ord_file_name = argv[1];
394 strcpy( buffer, dot_file_name );
396 printf(
"output special case: buffer = %s, dot_file_name = %s\n",
397 buffer, dot_file_name );
399 char * base_name_ptr =
base_name( buffer );
401 printf(
"output special case: buffer = %s, base = %s\n",
402 buffer, base_name_ptr );
405 = (
char *) calloc( strlen(base_name_ptr) + 1,
sizeof(char) );
410 readGraph( dot_file_name, ord_file_name );
420 Nodeptr middle_node = middle_layer->
nodes[ middle_node_position ];
432 writeDot( file_name_buffer, graph_name_buffer, comment_buffer,
449 best_edge_crossings_order
453 best_total_stretch_order
457 best_bottleneck_stretch_order
461 best_favored_crossings_order
475 printf(
"after preprocessor, runtime = %f\n",
RUNTIME );
483 printf(
"after heuristic, runtime = %f\n",
RUNTIME );
545 free( best_crossings_order );
547 free( best_edge_crossings_order );
549 free( best_total_stretch_order );
551 free( best_bottleneck_stretch_order );
554 free( best_favored_crossings_order );
void staticBarycenter(void)
static void printUsage(void)
int main(int argc, char *argv[])
static char output_file_name[MAX_NAME_LENGTH]
enum adjust_weights_enum adjust_weights
void maximumCrossingsNode(void)
void maximumStretchEdge(void)
int numberOfFavoredEdges(void)
void capture_preprocessing_stats(void)
void cleanup_order(Orderptr ord_info)
void maximumCrossingsEdge(void)
Interface for functions implementing all of the heuristics Those labeled parallel are designed specif...
const Edgeptr * favoredEdges(void)
static char buffer[MAX_NAME_LENGTH]
Functions for setting up priority edges and retrieving the number of crossings involving them...
void maximumCrossingsEdgeWithSifting(void)
bool end_of_iteration(void)
Global variables, functions, and parameters specified on the command line.
Definitions common to all edge crossing heuristic source files.
void capture_post_processing_stats(void)
void breadthFirstSearch(void)
enum pareto_objective_enum pareto_objective
enum sift_option_enum sift_option
Functions for reporting various statistics about the graph and the outcomes.
void capture_heuristic_stats(void)
void createOrdFileName(char *output_file_name, const char *appendix)
void readGraph(const char *dot_file, const char *ord_file)
Orderptr best_bottleneck_stretch_order
void writeDot(const char *dot_file_name, const char *graph_name, const char *header_information, Edgeptr *edge_list, int edge_list_length)
implementation of utilities that maintain information about channels; eventually these will replace t...
void modifiedBarycenter(void)
void restore_order(Orderptr ord_info)
Definition of functions for reading and writing graphs.
bool standard_termination
void upDownBarycenter(void)
Definition of functions that keep track of and update the number of crossings for each node...
struct order_struct * Orderptr
data structure and function headers for saving/restoring order information.
static void runPreprocessor(void)
Definition of data structures and access functions for a layered graph.
void capture_beginning_stats(void)
void print_graph_statistics(FILE *output_stream)
void createFavoredEdgeInfo(char *file_name_buffer, char *graph_name_buffer, char *comment_buffer)
static bool do_post_processing
enum mce_option_enum mce_option
void print_run_statistics(FILE *output_stream)
void slabBarycenter(void)
void init_genrand(unsigned long s)
Orderptr best_total_stretch_order
void evenOddBarycenter(void)
void init_order(Orderptr ord_info)
static char * base_name(char *buffer)
void init_crossing_stats(void)
void updateAllCrossings(void)
void middleDegreeSort(void)
int numberOfCrossings(void)
Orderptr best_crossings_order
void writeOrd(const char *ord_file)
void initPriorityEdges(void)
static void runHeuristic(void)
void rotatingBarycenter(void)
Header for a simple function to compute CPU user milliseconds.
void depthFirstSearch(void)
enum sifting_style_enum sifting_style
Orderptr best_favored_crossings_order
Orderptr best_edge_crossings_order
void createFanoutList(Nodeptr node)
Takes all the edges that are accessible via a path from the node and adds them to the priority list...