32 int total_of_positions = 0;
34 if( orientation !=
UPWARD )
37 for( adj_index = 0; adj_index < node->
down_degree; adj_index++ )
46 for( adj_index = 0; adj_index < node->
up_degree; adj_index++ )
52 if( total_degree > 0 )
53 node->
weight = (double) total_of_positions / total_degree;
62 printf(
" node_weight, node = %d, weight = %f\n", node->
id, node->
weight );
74 printf(
"-> balanced_node_weight, node = %d\n", node->
id );
78 int total_of_positions;
81 total_of_positions = 0;
83 for( adj_index = 0; adj_index < degree; adj_index++ ) {
87 double downward_average;
88 if ( degree > 0 ) downward_average = (double) total_of_positions / degree;
89 else downward_average = 0;
92 total_of_positions = 0;
94 for( adj_index = 0; adj_index < degree; adj_index++ ) {
98 double upward_average;
99 if ( degree > 0 ) upward_average = (double) total_of_positions / degree;
100 else upward_average = 0;
102 node->
weight = (downward_average + upward_average) / 2;
104 printf(
"<- balanced_node_weight, node = %d, weight = %4.1f," 105 " down_avg = %4.1f, up_avg = %4.1f\n",
106 node->
id, node->
weight, downward_average, upward_average );
130 if( i == 0 ) node->
weight = 0;
133 printf(
" adjust_weight (left), node = %s, weight = %f\n",
153 double * temp_weights;
156 temp_weights = (
double *) calloc( num_nodes,
sizeof(
double) );
157 for (
int i = 0; i < num_nodes; i++ ) {
161 for (
int i = 0; i < num_nodes; i++ ) {
163 double weight = parallel ? temp_weights[i] : layerptr->
nodes[i]->
weight;
165 if ( weight != -1 )
continue;
167 double left_weight = -1;
168 double right_weight = -1;
170 left_weight = parallel ? temp_weights[i-1] : layerptr->
nodes[i-1]->
weight;
172 if ( i < num_nodes - 1 ) {
173 right_weight = parallel ? temp_weights[i+1] : layerptr->
nodes[i+1]->
weight;
178 if ( left_weight != -1 && right_weight != -1 ) {
179 node->
weight = (left_weight + right_weight) / 2;
181 else if ( left_weight != -1 ) {
183 node->
weight = left_weight;
185 else if ( right_weight != -1 ) {
187 node->
weight = right_weight;
191 node->
weight = parallel ? 0 : left_weight;
194 printf(
" adjust_weight (avg), node = %s, weight = %f\n",
199 free( temp_weights );
209 printf(
"-> barycenterWeights, layer = %d, orientation = %d" 210 ", balanced_weight = %d\n",
223 for(i = 0 ; i < num_nodes; i++ )
235 printf(
"<- barycenterWeights\n" );
241 int layer = starting_layer;
262 int layer = starting_layer;
263 for( ; layer >= 0; layer-- )
enum adjust_weights_enum adjust_weights
Interface for functions implementing all of the heuristics Those labeled parallel are designed specif...
static void balanced_node_weight(Nodeptr node)
bool end_of_iteration(void)
Global variables, functions, and parameters specified on the command line.
Definitions common to all edge crossing heuristic source files.
bool barycenterDownSweep(int starting_layer)
Interface for functions that perform various sorts. All sorts are stable.
void updateCrossingsForLayer(int layer)
Definition of functions for reading and writing graphs.
static void node_weight(Nodeptr node, Orientation orientation)
static void adjust_weights_left(int layer)
Definition of functions that keep track of and update the number of crossings for each node...
Definition of data structures and access functions for a layered graph.
void tracePrint(int layer, const char *message)
void barycenterWeights(int layer, Orientation orientation)
void layerSort(int layer)
static void adjust_weights_avg(int layer)
interface for various functions related to barycenter heuristics
bool barycenterUpSweep(int starting_layer)