package OurApplication; import graph.*; import logging.Algorithm; import logging.LogElementList; import visualizationElements.Vertex; import java.awt.*; import java.util.Random; import java.util.Vector; /** * This class provides an example for using logging.Algorithm. * It sums up integer number starting with 0 up to the maximum value specified in the parameter area. * @see Algorithm * @author MSch�fer * DHBW Stuttgart/Campus Horb AI2008
*
*/ public class OurAlgorithm extends Algorithm { private graph.Graph currentGraph; public OurAlgorithm() { super(); } /** * Creates a sum up algorithm. * @param parameterArea the sum up parameter area the algorithm gets its parameters from */ public OurAlgorithm(OurParameterArea parameterArea){ super(parameterArea,"GraphAlgorithm"); } /** * Overwritten from super class. * Runs the algorithm.. * Returns the LogElementList produced by the algorithm processing. * Adds integer number starting with 0 up to the maximum value. * @return a LogElementList containing the algorithm processing single steps */ public LogElementList run() { Random random = new Random(); MarkedVertex start = this.currentGraph.getAllVertexes().get(random.nextInt(this.currentGraph.getAllVertexes().size())); MarkedVertex end = this.currentGraph.getAllVertexes().get(random.nextInt(this.currentGraph.getAllVertexes().size())); System.out.println(start.getName() + " to " + end.getName()); this.currentGraph.getShortestPathDijkstra(start, end); return this.currentGraph.getLogList(); } public void setCurrentGraph(graph.Graph graph) { this.currentGraph = graph; } }