2024-06-27 13:05:22 +00:00
|
|
|
|
package OurApplication;
|
|
|
|
|
|
2024-07-01 15:08:11 +00:00
|
|
|
|
import graph.*;
|
2024-06-27 13:05:22 +00:00
|
|
|
|
import logging.Algorithm;
|
|
|
|
|
import logging.LogElementList;
|
|
|
|
|
|
2024-07-01 15:08:11 +00:00
|
|
|
|
import java.util.Random;
|
|
|
|
|
|
2024-06-27 13:05:22 +00:00
|
|
|
|
/**
|
|
|
|
|
* 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<EFBFBD>fer
|
|
|
|
|
* DHBW Stuttgart/Campus Horb AI2008<br>
|
|
|
|
|
* <br>
|
|
|
|
|
*/
|
|
|
|
|
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(){
|
|
|
|
|
LogElementList<OurLogElement>logList = new LogElementList<OurLogElement>();
|
2024-07-01 15:08:11 +00:00
|
|
|
|
for(int x=1;x<=10;x++){
|
|
|
|
|
Random random = new Random();
|
|
|
|
|
DirectedGraph<VertexMarking, EdgeMarking> 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<VertexMarking> i: myGraph.getAllVertexes()) {
|
|
|
|
|
myGraph.addEdge(new MarkedEdge<>("a", i, myGraph.getAllVertexes().get(random.nextInt(myGraph.getAllVertexes().size())), null, random.nextInt(1, 10)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (MarkedVertex<VertexMarking> i: myGraph.getAllVertexes()) {
|
|
|
|
|
myGraph.addEdge(new MarkedEdge<>("a", i, myGraph.getAllVertexes().get(random.nextInt(myGraph.getAllVertexes().size())), null, random.nextInt(1, 10)));
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-27 13:05:22 +00:00
|
|
|
|
try{
|
2024-07-01 15:08:11 +00:00
|
|
|
|
logList.add(new OurLogElement(x, "Value", x, myGraph));
|
2024-06-27 13:05:22 +00:00
|
|
|
|
}
|
|
|
|
|
catch(OutOfMemoryError e){
|
|
|
|
|
|
2024-07-01 15:08:11 +00:00
|
|
|
|
System.err.println("Out of memory");
|
2024-06-27 13:05:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return logList;
|
|
|
|
|
}
|
|
|
|
|
}
|