1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#include "tsp.h"
#include <stdio.h>
#include <stdlib.h>
#ifndef PLAIN
#include <cm/cmmd.h>
#include "mem-ref.h"
#endif
#ifdef VERIFY_AFFINITIES
#include "affinity.h"
CHECK2(Tree,left,right,tree)
#endif
int flag;
int __NumNodes, __NDim;
int mylog(int num)
{
int j=0,k=1;
while(k<num) { k*=2; j++; }
return j;
}
int dealwithargs(void)
{
int num;
flag = 0;
__NumNodes = 4;
__NDim = mylog(__NumNodes);
num = 150000;
return num;
}
void print_tree(Tree t)
{
Tree left,right;
double x,y;
if (!t) return;
x = t->x; y = t->y;
chatting("x=%f,y=%f\n",x,y);
left = t->left; right=t->right;
print_tree(left);
print_tree(right);
}
void print_list(Tree t)
{
Tree tmp;
double x,y;
if (!t) return;
x = t->x; y = t->y;
chatting("%f %f\n",x,y);
for (tmp=t->next; tmp!=t; tmp=tmp->next)
{
x = tmp->x; y = tmp->y;
chatting("%f %f\n",x,y);
}
}
double wallclock;
int main()
{
Tree t;
int num;
num = dealwithargs();
chatting("Building tree of size %d\n",num);
t=build_tree(num,0,0,__NumNodes,0.0,1.0,0.0,1.0);
#ifdef VERIFY_AFFINITIES
Docheck_tree(t);
#endif
if (!flag) chatting("Past build\n");
if (flag) chatting("newgraph\n");
if (flag) chatting("newcurve pts\n");
timer_start(0);
tsp(t,150,__NumNodes);
timer_stop(0);
if (flag) print_list(t);
if (flag) chatting("linetype solid\n");
chatting("Time for TSP = %f\n", timer_elapsed(0));
#ifdef VERIFY_AFFINITIES
Print_Accumulated_list();
#endif
#ifdef FUTURES
__ShutDown(0);
#endif
exit(0);
}
|