diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-11-24 21:56:36 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2013-11-24 21:56:36 +0100 |
commit | 8211bf815dbcf193439fc3f0927a5e9de1bce3bc (patch) | |
tree | 8e5fa976fb43cfb38efc2a9bd2fa8d111b250a27 /main.c | |
parent | 7dc7d76a225a0eeac49689058bcb67c5fe328c33 (diff) | |
download | AlgoProg-Projet-8211bf815dbcf193439fc3f0927a5e9de1bce3bc.tar.gz AlgoProg-Projet-8211bf815dbcf193439fc3f0927a5e9de1bce3bc.zip |
Implemented basic algorithm for finding maximum clique... no optimizations.
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 33 |
1 files changed, 33 insertions, 0 deletions
@@ -8,7 +8,40 @@ */ #include "sets.h" +#include "graph.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); + } + } 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); + } + } +} int main() { + graph g = load_graph(stdin); + dump_graphviz(g, stdout); + + // do stuff with graph + set max_clique = empty_set(g->N); + set init_s = full_set(g->N); + set init_k = empty_set(g->N); + max_clique_a(g, init_k, init_s, &max_clique); + printf("Max clique: "); dump_set(max_clique); + + delete_graph(g); return 0; } |