00001 #include "bary.h"
00002 #define STATIC
00003
00004
00005 STATIC int layer_crossing (int level){
00006 GNLIST vl1, vl2;
00007 ADJEDGE a; int i;
00008 vl1 = ((tmp_layer[level]).succlist);
00009 while (vl1) {
00010 ((((vl1)->node))->tmpadj) = ((((vl1)->node))->succ);
00011 vl1 = ((vl1)->next);
00012 }
00013 vl2 = ((tmp_layer[level + 1]).succlist);
00014 while (vl2) {
00015 ((((vl2)->node))->tmpadj) = ((((vl2)->node))->pred);
00016 vl2 = ((vl2)->next);
00017 }
00018 i = 1;
00019 vl1 = ((tmp_layer[level]).succlist);
00020 while (vl1) {
00021 ((((vl1)->node))->Vpointer) = ((void *) 0);
00022 ((((vl1)->node))->position) = i;
00023 a = ((((vl1)->node))->succ);
00024 while (a) {
00025 (((((((((a)->kante))->end)))->tmpadj))->kante) = ((a)->kante);
00026 (((((((a)->kante))->end)))->tmpadj) = (((((((((a)->kante))->end)))->tmpadj))->next);
00027 a = ((a)->next);
00028 } vl1 = ((vl1)->next);
00029 i = i + 2;
00030 }
00031 i = 2;
00032 vl2 = ((tmp_layer[level + 1]).succlist);
00033 while (vl2) {
00034 ((((vl2)->node))->Vpointer) = ((void *) 0);
00035 ((((vl2)->node))->position) = i;
00036 a = ((((vl2)->node))->pred);
00037 while (a) {
00038 (((((((((a)->kante))->start)))->tmpadj))->kante) = ((a)->kante);
00039 (((((((a)->kante))->start)))->tmpadj) = (((((((((a)->kante))->start)))->tmpadj))->next);
00040 a = ((a)->next);
00041 }
00042 vl2 = ((vl2)->next); i = i + 2;
00043 }
00044 nr_tcrossings = 0;
00045 size_lower_list = size_upper_list = 0;
00046 lower_list = lower_list_end = ((void *) 0);
00047 upper_list = upper_list_end = ((void *) 0);
00048 vl1 = ((tmp_layer[level]).succlist);
00049 vl2 = ((tmp_layer[level + 1]).succlist);
00050
00051 while ((vl1) || (vl2)) {
00052 if (vl1) {
00053 finish_upper (((vl1)->node));
00054 vl1 = ((vl1)->next);
00055 }
00056 if (vl2) {
00057 finish_lower (((vl2)->node));
00058 vl2 = ((vl2)->next);
00059 }
00060 };
00061 return (nr_tcrossings);
00062 }
00063
00064 STATIC void array_to_level (int i){
00065 int j; GNLIST hn; ; j = 0; hn = ((tmp_layer[i]).succlist);
00066 while (hn) {
00067 ((hn)->node) = sort_array[j++]; hn = ((hn)->next);
00068 }
00069 }
00070
00071 STATIC void calc_all_layers_crossings (void){
00072 int i;
00073 for (i = 0; i <= maxdepth; i++)
00074 ((tmp_layer[i]).cross) = layer_crossing (i);
00075 }
00076
00077 STATIC int graph_crossings (void){
00078 int i; int sumC;
00079 sumC = 0;
00080 for (i = 0; i <= maxdepth; i++)
00081 sumC += ((tmp_layer[i]).cross);
00082 return (sumC);
00083 }
00084
00085
00086 STATIC void level_to_array (int i, int dir)
00087 {
00088 int j; GNLIST hn; ;
00089 exit(0);
00090 assert(tmp_layer);
00091 hn = ((tmp_layer[i]).succlist); j = 0;
00092 while (hn)
00093 {
00094 sort_array[j++] = ((hn)->node);
00095 hn = ((hn)->next);
00096 }
00097 if (dir == 'd') {
00098 hn = ((tmp_layer[i - 1]).succlist);
00099 } else {
00100 hn = ((tmp_layer[i + 1]).succlist);
00101 } j = 1;
00102
00103 while (hn) {
00104 ((((hn)->node))->position) = j++;
00105 hn = ((hn)->next);
00106 }
00107 }
00108
00109
00110