#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 GenRandomGraphCmd(SCM n, SCM p)
{
        Graph *gr;
        if (!INTEGERP(n))
                Err("gen-random-graph: bad arg 1, <integer> expected", n);
        if (!FLONUMP(p))
                Err("gen-random-graph: bad arg 2, <number> expected", n);
	int sz = INTEGER(n);
	double prob = FLONM(p);
        Graph *g = GenRandomGraph(sz, prob);
        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_RandomGraph_Wrapper()
{
        STk_add_new_cpp_primitive("gen-random-graph", tc_subr_2,
                               (PRIMITIVE (*)(...))GenRandomGraphCmd);
}
