summaryrefslogtreecommitdiff
path: root/algos.c
blob: 07c667adf0aa544e8051adeade8fa3a7a85042d6 (plain) (blame)
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
#include "algos.h"

void max_clique_a(const graph g, set k, set c, set *mc) {
	if (is_set_empty(c)) {
		if (set_size(k) > set_size(*mc)) {
			delete_set(*mc);
			*mc = copy_set(k);
			printf("Found new max clique: "); dump_set(*mc); fflush(stdout);
		}
	} else {
		set cc = copy_set(c);
		while (!(is_set_empty(cc))) {
			int x = elt_of_set(cc);
			set_remove_ip(x, cc);

			set k2 = set_add(x, k);
			set c2 = set_inter(c, graph_neighbours(g, x));
			max_clique_a(g,k2, c2, mc);
			delete_set(k2);
			delete_set(c2);
		}
		delete_set(cc);
	}
}

void max_clique_b(const graph g, set k, set c, set a, set *mc) {
	if (is_set_empty(c)) {
		if (set_size(k) > set_size(*mc)) {
			delete_set(*mc);
			*mc = copy_set(k);
			printf("Found new max clique: "); dump_set(*mc); fflush(stdout);
		}
	} else {
	    set at = copy_set (a);
		while (!(is_set_empty(at))) {
			int x = elt_of_set(at);
			set_remove_ip(x, at);

			set k2 = set_add(x, k);
			set c2 = set_inter(c, graph_neighbours(g, x));
			set a2 = set_inter(at,  graph_neighbours(g, x));
			
			max_clique_b(g,k2, c2, a2, mc);
			delete_set(k2);
			delete_set(c2);
			delete_set(a2);
		}
		delete_set(at);
	}
}

void max_clique_c(const graph g, set k, set c, set a, set *mc) {
	if (is_set_empty(c)) {
		if (set_size(k) > set_size(*mc)) {
			delete_set(*mc);
			*mc = copy_set(k);
			printf("Found new max clique: "); dump_set(*mc); fflush(stdout);
		}
	} else {
		//TODO
	}
}