#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<Edge*> Bridges(Graph *g, char *graph_view)
{
	Set<Edge*> result;
	if (!g) return result;

	DepthFirstSearch(g);
	Vertex** vertices = g->vertexStart();
	int i, order = g->order();;
	Vertex *dfs_pred;
	Edge *bridge;
	int dfs_starttime, dfs_low;

	for (i=0; i<order; i++) {
		getAttribute((GraphObject*) vertices[i], 
				"starttime", dfs_starttime);
		getAttribute((GraphObject*) vertices[i], 
				"low", dfs_low);
		if (dfs_low == dfs_starttime) {
			getAttribute((GraphObject*) vertices[i], 
				"pred", dfs_pred);
			if (dfs_pred) {
				bridge = g->isEdge(dfs_pred, vertices[i]);
				result.insert(bridge);
		        	animateEdge(bridge, graph_view, "width", 
					"width", ALG_STEP, 8);
			}
		}
	}
	return result;
}
