-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.c
More file actions
73 lines (51 loc) · 936 Bytes
/
Copy pathgraph.c
File metadata and controls
73 lines (51 loc) · 936 Bytes
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
#include "graph.h"
void init_vertex_random(struct vertex* v)
{
int i;
for(i=0; i<MAX_VERTEX; i++)
{
v[i].x = drand48();
v[i].y = drand48();
v[i].level = i;
}
}
void init_edge_random(struct edge* e)
{
int i;
for(i=0; i<MAX_EDGE; i++)
{
e[i].n1 = random() % MAX_VERTEX;
do { e[i].n2 = random() % MAX_VERTEX; }
while( e[i].n1 == e[i].n2);
e[i].column = i;
}
}
void init_graph_random(struct graph* g)
{
struct timeval tv;
int i,j;
gettimeofday(&tv, NULL);
srand(tv.tv_usec);
//srand(23212);
init_vertex_random(g->v);
init_edge_random(g->e);
for(i=0; i<MAX_VERTEX; i++)
for(j=0; j<MAX_EDGE; j++)
g->grid[i][j] = 0;
tripode_select(g);
}
int main()
{
struct graph g;
init_graph_random(&g);
// print_cls(&g, 100, 180);
//compact(&g);
make_sp(&g);
// debug_tree(&g);
remove_cross(&g);
compact(&g);
set_centres(&g);
print_cls(&g, 50, 250);
// print_graph(&g);
return 0;
}