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


Set<Vertex*> ArticulationPoints(Graph *g, char *graph_view)
{
	Set<Vertex*> result;
	if (!g) return result;

	DepthFirstSearch(g);
	Vertex** vertices = g->vertexStart();
	int i, vsize, order = g->order();;
	int child_dfs_low, parent_dfs_num;
	Vertex *dfs_pred;
	int num_root_dfs_children=0;

	for (i=0; i<order; i++) {
		Vertex *child = vertices[i];
		Vertex *parent;
		getAttribute((GraphObject*) child, "low", child_dfs_low);
		getAttribute((GraphObject*) child, "pred", parent);
		if (parent == vertices[0])
			num_root_dfs_children++;
		if (parent) {
			getAttribute((GraphObject*) parent, "starttime", 
				parent_dfs_num);
			if ((parent_dfs_num > 1) && 
			     (child_dfs_low >= parent_dfs_num)) {
				result.insert(parent);
				getAttribute((GraphObject*)parent, 
					     "size", vsize);
		        	animateVertex(parent, graph_view, 
					      "size", "size", INIT_STEP, vsize);
			}
		}
	}
	if (num_root_dfs_children > 1) {
		result.insert(vertices[0]);
		getAttribute((GraphObject*)vertices[0], "size", vsize);
	      	animateVertex(vertices[0], graph_view, 
					      "size", "size", INIT_STEP, vsize);
	}
	return result;
}
