code: public void breakCycles()
  	{
  		for (GraphObject go : new ArrayList<GraphObject>(result))
  		{
  			if (go instanceof Node)
  			{
  				Node node = (Node) go;
  
  				for (Edge edge : node.getDownstream())
  				{
  					if (result.contains(edge) && !isSafe(node, edge))
  					{
  						result.remove(edge);
  					}
  				}
  			}
  		}
  	}
docs: Run the algorithm.