#include<stk.h>
#include<LINK/stkWrapper/LINK_STk.h>
#include<LINK/stkWrapper/Wrapper.h>
#include<LINK/stkWrapper/Register.h>
#include<LINK/generator/Generators.h>
#include<LINK/graph/DBinGraph.h>
#include<LINK/graph/Graph.h>

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

static PRIMITIVE GenLatkaTournamentCmd(SCM i, SCM k)
{
        Graph *gr;
        if (!INTEGERP(i))
                Err("gen-latka-tournament: bad arg 1, <integer> expected", i);
        if (!INTEGERP(k))
                Err("gen-latka-tournament: bad arg 2, <integer> expected", i);
	int sz = INTEGER(i);
	int spread = INTEGER(k);
        Graph *g = GenLatkaTournament(sz, spread);
        Register<Graph>::createEntry(Wrapper<DBinGraph>::type,
                                     Wrapper<DBinGraph>::name, g);
        Graph **gp = new Graph*(g);

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

void gen_LatkaTournament_Wrapper()
{
        STk_add_new_cpp_primitive("gen-latka-tournament", tc_subr_2,
                               (PRIMITIVE (*)(...))GenLatkaTournamentCmd);
}
