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

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

static PRIMITIVE SupermarketHyperGraphCmd(SCM g)
{
        Graph *gr;
        if (!(gr = getGraph(g)))
                Err("supermarket-hypergraph: bad arg 1, graph expected", g);
        Graph* h = SupermarketHyperGraph(gr,0);

        return STk_make_CXXwrapper(Wrapper<MUHyperGraph*>::type,
                Wrapper<MUHyperGraph*>::name, (void *) h, LINK_DYNAMIC);
}

static PRIMITIVE SupermarketHyperGraphAnimCmd(SCM g, SCM view)
{
        Graph *gr;
        if (!(gr = getGraph(g)))
                Err("supermarket-hypergraph: bad arg 1, graph expected", g);
	char *name = getViewName(view);
	int k = initAnimation();
	animationWindows(k, name);
        Graph *h = SupermarketHyperGraph(gr,name);

        return STk_make_CXXwrapper(Wrapper<MUHyperGraph*>::type,
                Wrapper<MUHyperGraph*>::name, (void *) h, LINK_DYNAMIC);
}

void gen_SupermarketHyperGraph_Wrapper()
{
        STk_add_new_cpp_primitive("supermarket-hypergraph", tc_subr_1,
                             (PRIMITIVE (*)(...))SupermarketHyperGraphCmd);
        STk_add_new_cpp_primitive("supermarket-hypergraph*", tc_subr_2,
                             (PRIMITIVE (*)(...))SupermarketHyperGraphAnimCmd);
}
