#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 GenCycleCmd(SCM n)
{
        Graph *gr;
        if (!INTEGERP(n))
                Err("gen-cycle: bad arg 1, <integer> expected", n);
	int sz = INTEGER(n);
        Graph *g = GenCycle(sz);
        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_Cycle_Wrapper()
{
        STk_add_new_cpp_primitive("gen-cycle", tc_subr_1,
                               (PRIMITIVE (*)(...))GenCycleCmd);
}
#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 GenCompleteGraphCmd(SCM n)
{
        Graph *gr;
        if (!INTEGERP(n))
                Err("gen-cycle: bad arg 1, <integer> expected", n);
	int sz = INTEGER(n);
        Graph *g = GenCompleteGraph(sz);
        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_CompleteGraph_Wrapper()
{
        STk_add_new_cpp_primitive("gen-complete-graph", tc_subr_1,
                               (PRIMITIVE (*)(...))GenCompleteGraphCmd);
}
#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);
}
#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);
}
#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/UHyperGraph.h>
#include<LINK/graph/Graph.h>

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

static PRIMITIVE GenUHyperGraphKUCmd(SCM n, SCM m, SCM k)
{
        Graph *gr;
        if (!INTEGERP(n))
            Err("gen-uniform-hypergraph: bad arg 1, #v (<integer>) expected",n);
        if (!INTEGERP(m))
            Err("gen-uniform-hypergraph: bad arg 1, #e (<integer>) expected",m);
        if (!INTEGERP(k))
            Err("gen-uniform-hypergraph: bad arg 1, #v (<integer>) expected",k);
	int num_verts = INTEGER(n);
	int num_edges = INTEGER(m);
	int edge_size = INTEGER(k);
        Graph *g = GenUHyperGraphKU(num_verts, num_edges, edge_size);
        Register<Graph>::createEntry(Wrapper<UBinGraph>::type,
                                     Wrapper<UBinGraph>::name, g);
        Graph **gp = new Graph*(g);

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

void gen_UHyperGraphKU_Wrapper()
{
        STk_add_new_cpp_primitive("gen-uniform-hypergraph", tc_subr_3,
                               (PRIMITIVE (*)(...))GenUHyperGraphKUCmd);
}
