#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 GenGridGraphCmd(SCM rows, SCM cols)
{
        Graph *gr;
        if (!INTEGERP(rows))
             Err("gen-grid-graph: bad arg 1, #rows (<integer>) expected", rows);
        if (!INTEGERP(cols))
             Err("gen-grid-graph: bad arg 1, #cols (<integer>) expected", cols);
	int r = INTEGER(rows);
	int c = INTEGER(cols);
        Graph *g = GenGridGraph(r, c);
        Register<Graph>::createEntry(Wrapper<UBinGraph>::type,
                                     Wrapper<UBinGraph>::name, g);
        Graph **gp = new Graph*(g);

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

void gen_GridGraph_Wrapper()
{
        STk_add_new_cpp_primitive("gen-grid-graph", tc_subr_2,
                               (PRIMITIVE (*)(...))GenGridGraphCmd);
}
