#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/UBinGraph.h>
#include<LINK/graph/Graph.h>

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

static PRIMITIVE GenRegularCmd(SCM n, SCM k)
{
        Graph *gr;
        if (!INTEGERP(n))
             Err("gen-regular-graph: bad arg 1, #verts (<integer>) expected",n);
        if (!INTEGERP(k))
             Err("gen-regular-graph: bad arg 2, degree (<integer>) expected",k);
	int r = INTEGER(n);
	int c = INTEGER(k);
        MUBinGraph *g = GenRegularGraph(r, c);
        Register<Graph>::createEntry(Wrapper<MUBinGraph>::type,
                                     Wrapper<MUBinGraph>::name, g);
        Graph **gp = new Graph*(g);

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

void gen_Regular_Wrapper()
{
        STk_add_new_cpp_primitive("gen-regular-graph", tc_subr_2,
                               (PRIMITIVE (*)(...))GenRegularCmd);
}
