package OurApplication; import graph.*; import logging.Algorithm; import logging.LogElementList; import java.util.Random; /** * 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{ 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(){ LogElementListlogList = new LogElementList(); for(int x=1;x<=10;x++){ Random random = new Random(); DirectedGraph myGraph = new DirectedGraph<>(); for (int i = 0; i < 10; i++) { myGraph.addVertex(new MarkedVertex<>(String.valueOf(i), null, random.nextInt(i, 350), random.nextInt(i, 350))); } for (MarkedVertex i: myGraph.getAllVertexes()) { myGraph.addEdge(new MarkedEdge<>("a", i, myGraph.getAllVertexes().get(random.nextInt(myGraph.getAllVertexes().size())), null, random.nextInt(1, 10))); } for (MarkedVertex i: myGraph.getAllVertexes()) { myGraph.addEdge(new MarkedEdge<>("a", i, myGraph.getAllVertexes().get(random.nextInt(myGraph.getAllVertexes().size())), null, random.nextInt(1, 10))); } try{ logList.add(new OurLogElement(x, "Value", x, myGraph)); } catch(OutOfMemoryError e){ System.err.println("Out of memory"); } } return logList; } }