#include<stk.h>
#include<LINK/stkWrapper/LINK_STk.h>
#include<LINK/stkWrapper/Wrapper.h>
#include<LINK/algorithm/Algorithms.h>
#include<LINK/basic/Set.h>
#include<LINK/graph/Graph.h>
#include<LINK/graph/Edge.h>

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

static PRIMITIVE ArticulationPointsCmd(SCM g)
{
        Graph *gr;
        if (!(gr = getGraph(g)))
                Err("articulation-points: bad arg 1, graph expected", g);
        Set<Vertex*> s = ArticulationPoints(gr,0);
        Set<Vertex*>* sp = new Set<Vertex*>(s);

        return STk_make_CXXwrapper(Wrapper<Set<Vertex*> >::type,
                Wrapper<Set<Vertex*> >::name, (void *) sp, LINK_DYNAMIC);
}

static PRIMITIVE ArticulationPointsAnimCmd(SCM g, SCM view)
{
        Graph *gr;
        if (!(gr = getGraph(g)))
                Err("articulation-points: bad arg 1, graph expected", g);
	char *name = getViewName(view);
	int k = initAnimation();
	animationWindows(k, name);
        Set<Vertex*> s = ArticulationPoints(gr,name);
        Set<Vertex*>* sp = new Set<Vertex*>(s);

        return STk_make_CXXwrapper(Wrapper<Set<Vertex*> >::type,
                Wrapper<Set<Vertex*> >::name, (void *) sp, LINK_DYNAMIC);
}

void gen_ArticulationPoints_Wrapper()
{
        STk_add_new_cpp_primitive("articulation-points", tc_subr_1,
                               (PRIMITIVE (*)(...))ArticulationPointsCmd);
        STk_add_new_cpp_primitive("articulation-points*", tc_subr_2,
                               (PRIMITIVE (*)(...))ArticulationPointsAnimCmd);
}
