ProjektGraph/graph/Display.java
cmerkens 0904358705 Reset main
Revert "Für Christian"

This reverts commit 213638ad16.

Revert "Visualisation progress"

This reverts commit 12dbadf5e1.

Revert "OurApplication test"This reverts commit 6b0caa1a5e.

Revert "Visualisation tests"

This reverts commit cf63dddf51.
2024-07-03 20:18:47 +02:00

33 lines
1.3 KiB
Java

package graph;
import java.util.Random;
public class Display {
public static void main(String[] args) {
DirectedGraph<VertexMarking, EdgeMarking> myGraph = new DirectedGraph<>();
for (int i = 0; i < 10; i++) {
myGraph.addVertex(new MarkedVertex<>(String.valueOf(i), null));
}
Random random = new Random();
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)));
}
System.out.println(myGraph.toString());
MarkedVertex<VertexMarking> start = myGraph.getAllVertexes().get(random.nextInt(myGraph.getAllVertexes().size()));
MarkedVertex<VertexMarking> end = myGraph.getAllVertexes().get(random.nextInt(myGraph.getAllVertexes().size()));
System.out.println(start.getName() + " to " + end.getName());
System.out.println(myGraph.getShortestPathDijkstra(start, end));
}
}