112 lines
3.5 KiB
Java
112 lines
3.5 KiB
Java
package OurApplication;
|
||
|
||
import graph.*;
|
||
import logging.Algorithm;
|
||
import logging.LogElementList;
|
||
|
||
import java.awt.*;
|
||
import java.util.HashMap;
|
||
import java.util.PriorityQueue;
|
||
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<63>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>();
|
||
|
||
/*
|
||
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)));
|
||
}
|
||
|
||
try{
|
||
logList.add(new OurLogElement(x, "Value", x, myGraph));
|
||
}
|
||
catch(OutOfMemoryError e){
|
||
|
||
System.err.println("Out of memory");
|
||
}
|
||
}
|
||
*/
|
||
|
||
Random random = new Random();
|
||
DirectedGraph<VertexMarking, EdgeMarking> myGraph = new DirectedGraph<>();
|
||
for (int i = 0; i < 10; i++) {
|
||
|
||
myGraph.addVertex(new MarkedVertex<>(random.nextInt(i, 350), random.nextInt(i, 350), String.valueOf(i) + " :", Color.BLACK , null));
|
||
}
|
||
|
||
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)));
|
||
}
|
||
|
||
MarkedVertex<VertexMarking> start = myGraph.getAllVertexes().get(random.nextInt(myGraph.getAllVertexes().size()));
|
||
MarkedVertex<VertexMarking> end = myGraph.getAllVertexes().get(random.nextInt(myGraph.getAllVertexes().size()));
|
||
|
||
Vector<DirectedGraph<VertexMarking, EdgeMarking>> items = new Vector<>();
|
||
items = myGraph.DikstraVisualization(start, end);
|
||
|
||
for(DirectedGraph<VertexMarking, EdgeMarking> i : items){
|
||
logList.add(new OurLogElement(1, "Value", 1, i));
|
||
}
|
||
|
||
return logList;
|
||
}
|
||
|
||
|
||
|
||
//Erstelle eines zufälligen Graphen
|
||
//Auf den graphen Diktra aufrufen --> liefert Vektor mit Steps
|
||
//for each über die Steps und fügen sie zur Loglist hinzu
|
||
//return die Log list
|
||
|
||
|
||
|
||
|
||
}
|