-
Notifications
You must be signed in to change notification settings - Fork 2
/
graph.c
147 lines (134 loc) · 2.97 KB
/
graph.c
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
/**
*
* @Name : RamseyNumber/graph.c
* @Version : 1.0
* @Programmer : Max
* @Date : 2019-07-29
* @Released under : https://github.com/BaseMax/RamseyNumber/blob/master/LICENSE
* @Repository : https://github.com/BaseMax/RamseyNumber
*
**/
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#define FOR(index, start, end)\
for(uint64_t index=start; index<end;index++)
#define SET_PAIR(item, first, end) \
item.a=first;\
item.b=end;
typedef enum {
false,
true,
} bool;
typedef struct {
uint64_t a;
uint64_t b;
} pair;
typedef struct {
uint64_t a;
uint64_t b;
unsigned int c;
} color;
int art;
int count;
pair **items;
color *edges;
uint64_t edgesCount=0;
unsigned int randomColor() {
return rand() % count;
}
unsigned int found(uint64_t i, uint64_t j) {
FOR(i, 0, edgesCount) {
// printf("==>%d\n", i);
if(
(edges[i].a == i && edges[i].b == j) ||
(edges[i].a == j && edges[i].b == i)) {
return edges[i].c;
}
}
return -1;
}
int main(int argc, char const *argv[]) {
art=43;
count=2;
srand(time(0));
items=malloc(sizeof(pair*)*962598);
uint64_t first_limit=10000;
uint64_t first_limit_index=0;
edges=malloc(sizeof(color)*903);
edgesCount=0;
FOR(i, 0, art) {
FOR(j, i+1, art) {
SET_PAIR(edges[edgesCount], i+1, j+1);
edgesCount++;
}
}
uint64_t itemsCount=0;
FOR(i, 0, art) {
FOR(j, i+1, art) {
FOR(l, j+1, art) {
FOR(w, l+1, art) {
FOR(e, w+1, art) {
// printf("%d, %d, %d, %d, %d\n", i+1, j+1, l+1, w+1, e+1);
items[itemsCount]=malloc(sizeof(pair)*10);
SET_PAIR(items[itemsCount][0], i+1, j+1);
SET_PAIR(items[itemsCount][1], i+1, l+1);
SET_PAIR(items[itemsCount][2], i+1, w+1);
SET_PAIR(items[itemsCount][3], i+1, e+1);
SET_PAIR(items[itemsCount][4], j+1, l+1);
SET_PAIR(items[itemsCount][5], j+1, w+1);
SET_PAIR(items[itemsCount][6], j+1, e+1);
SET_PAIR(items[itemsCount][7], l+1, w+1);
SET_PAIR(items[itemsCount][8], l+1, e+1);
SET_PAIR(items[itemsCount][9], w+1, e+1);
itemsCount++;
}
}
}
}
}
while(1) {
check:
printf("%" PRIu64 "/%" PRIu64 "\n", first_limit_index+1, first_limit);
first_limit_index+=1;
if(first_limit_index == first_limit) {
printf("END, Limit.....");
exit(-1);
}
FOR(i, 0, edgesCount) {
edges[i].c=randomColor();
}
bool sameColor=false;
FOR(i, 0, itemsCount) {
bool checkContinue=true;
unsigned int color=-1;
FOR(j, 0, 10) {
if(color == -1) {
color=found(items[i][j].a, items[i][j].b);
continue;
}
else {
unsigned int tcolor=found(items[i][j].a, items[i][j].b);
// printf("==>%d\n", tcolor);
if(tcolor != color) {
checkContinue=false;
break;
}
}
}
if(checkContinue == true) {
sameColor=true;
goto check;
exit(1);
}
}
if(sameColor == false) {
printf("Done\n");
// printf("Colorize edges of the graph: " + str(edges));
exit(1);
}
}
printf("%" PRIu64 "\n", itemsCount);
return 0;
}