#include<stk.h>
#include<LINK/stkWrapper/LINK_STk.h>
#include<LINK/stkWrapper/Wrapper.h>
#include<LINK/algorithm/Algorithms.h>
#include<LINK/basic/Set.h>
#include<LINK/graph/Graph.h>

#include <stdio.h>
#include <stdlib.h>

static PRIMITIVE MaximalCliqueCmd(SCM g)
{
        Graph *gr;
        if (!(gr = getGraph(g)))
                Err("maximal-clique: bad arg 1, graph expected", g);
        Set<Vertex*> s = MaximalClique(gr,0);
        Set<Vertex*>* sp = new Set<Vertex*>(s);

        return STk_make_CXXwrapper(Wrapper<Set<Vertex*> >::type,
                Wrapper<Set<Vertex*> >::name, (void *) sp, LINK_DYNAMIC);
}

static PRIMITIVE MaximalCliqueAnimCmd(SCM g, SCM view)
{
        Graph *gr;
        if (!(gr = getGraph(g)))
                Err("dfs: bad arg 1, graph expected", g);
	char *name = getViewName(view);
	int k = initAnimation();
	animationWindows(k, name);
        Set<Vertex*> s = MaximalClique(gr,name);
        Set<Vertex*>* sp = new Set<Vertex*>(s);

        return STk_make_CXXwrapper(Wrapper<Set<Vertex*> >::type,
                Wrapper<Set<Vertex*> >::name, (void *) sp, LINK_DYNAMIC);
}

void gen_MaximalClique_Wrapper()
{
        STk_add_new_cpp_primitive("maximal-clique", tc_subr_1,
                               (PRIMITIVE (*)(...))MaximalCliqueCmd);
        STk_add_new_cpp_primitive("maximal-clique*", tc_subr_2,
                               (PRIMITIVE (*)(...))MaximalCliqueAnimCmd);
}
