Stable Version 3.0
This commit is contained in:
parent
0d5ff33a9d
commit
98edc9a28d
23
.idea/workspace.xml
generated
23
.idea/workspace.xml
generated
@ -9,16 +9,11 @@
|
|||||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurAlgorithm.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurAlgorithm.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/OurApplication/OurAlgorithm.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurAlgorithm.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurApplication.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurApplication.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/OurApplication/OurApplication.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurApplication.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurDrawArea.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurDrawArea.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/OurApplication/OurDrawArea.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurDrawArea.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurHybridWindow.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurHybridWindow.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurLogElement.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurLogElement.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/OurApplication/OurLogElement.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurLogElement.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/OurApplication/OurParameterArea.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurParameterArea.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/graph/DirectedGraph.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/DirectedGraph.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/graph/DirectedGraph.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/DirectedGraph.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/graph/Edge.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/Edge.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/graph/Graph.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/Graph.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/graph/Graph.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/Graph.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/graph/MarkedEdge.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/MarkedEdge.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/graph/MarkedEdge.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/MarkedEdge.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/graph/MarkedVertex.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/MarkedVertex.java" afterDir="false" />
|
|
||||||
<change beforePath="$PROJECT_DIR$/graph/UndirectedGraph.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/UndirectedGraph.java" afterDir="false" />
|
<change beforePath="$PROJECT_DIR$/graph/UndirectedGraph.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/UndirectedGraph.java" afterDir="false" />
|
||||||
<change beforePath="$PROJECT_DIR$/graph/Vertex.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/Vertex.java" afterDir="false" />
|
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
@ -37,16 +32,16 @@
|
|||||||
<option name="hideEmptyMiddlePackages" value="true" />
|
<option name="hideEmptyMiddlePackages" value="true" />
|
||||||
<option name="showLibraryContents" value="true" />
|
<option name="showLibraryContents" value="true" />
|
||||||
</component>
|
</component>
|
||||||
<component name="PropertiesComponent"><![CDATA[{
|
<component name="PropertiesComponent">{
|
||||||
"keyToString": {
|
"keyToString": {
|
||||||
"Application.Display.executor": "Run",
|
"Application.Display.executor": "Run",
|
||||||
"Application.OurApplication.executor": "Run",
|
"Application.OurApplication.executor": "Run",
|
||||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||||
"git-widget-placeholder": "Versuch__Christian",
|
"git-widget-placeholder": "Versuch__Christian",
|
||||||
"kotlin-language-version-configured": "true",
|
"kotlin-language-version-configured": "true",
|
||||||
"last_opened_file_path": "C:/Git/ProjektGraphMain"
|
"last_opened_file_path": "C:/Git/ProjektGraphMain"
|
||||||
}
|
}
|
||||||
}]]></component>
|
}</component>
|
||||||
<component name="RecentsManager">
|
<component name="RecentsManager">
|
||||||
<key name="CopyFile.RECENT_KEYS">
|
<key name="CopyFile.RECENT_KEYS">
|
||||||
<recent name="C:\Git\ProjektGraph" />
|
<recent name="C:\Git\ProjektGraph" />
|
||||||
|
@ -3,6 +3,7 @@ package OurApplication;
|
|||||||
import graph.*;
|
import graph.*;
|
||||||
import logging.Algorithm;
|
import logging.Algorithm;
|
||||||
import logging.LogElementList;
|
import logging.LogElementList;
|
||||||
|
import visualizationElements.Vertex;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@ -16,7 +17,9 @@ import java.util.Vector;
|
|||||||
* DHBW Stuttgart/Campus Horb AI2008<br>
|
* DHBW Stuttgart/Campus Horb AI2008<br>
|
||||||
* <br>
|
* <br>
|
||||||
*/
|
*/
|
||||||
public class OurAlgorithm extends Algorithm{
|
public class OurAlgorithm extends Algorithm {
|
||||||
|
|
||||||
|
private graph.Graph<VertexMarking, EdgeMarking> currentGraph;
|
||||||
|
|
||||||
public OurAlgorithm() {
|
public OurAlgorithm() {
|
||||||
super();
|
super();
|
||||||
@ -36,14 +39,23 @@ public class OurAlgorithm extends Algorithm{
|
|||||||
* Adds integer number starting with 0 up to the maximum value.
|
* Adds integer number starting with 0 up to the maximum value.
|
||||||
* @return a LogElementList containing the algorithm processing single steps
|
* @return a LogElementList containing the algorithm processing single steps
|
||||||
*/
|
*/
|
||||||
|
public LogElementList<OurLogElement> run() {
|
||||||
|
|
||||||
|
Random random = new Random();
|
||||||
|
|
||||||
|
MarkedVertex<VertexMarking> start = this.currentGraph.getAllVertexes().get(random.nextInt(this.currentGraph.getAllVertexes().size()));
|
||||||
|
MarkedVertex<VertexMarking> 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<VertexMarking, EdgeMarking> graph) {
|
||||||
public LogElementList<OurLogElement> run(){
|
this.currentGraph = graph;
|
||||||
LogElementList<OurLogElement> logList = new LogElementList<OurLogElement>();
|
|
||||||
|
|
||||||
// Hier müssen die Loggingelemente von Dikstra ankommen.
|
|
||||||
return logList;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
package OurApplication;
|
package OurApplication;
|
||||||
|
|
||||||
|
import graph.*;
|
||||||
import logging.LogElementList;
|
import logging.LogElementList;
|
||||||
import visualisation.HybridWindow;
|
import visualisation.HybridWindow;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This application provides an example for using logging and visualization packages.
|
* This application provides an example for using logging and visualization packages.
|
||||||
@ -56,6 +59,29 @@ public class OurApplication {
|
|||||||
frame.setVisible(true);
|
frame.setVisible(true);
|
||||||
|
|
||||||
|
|
||||||
|
Random random = new Random();
|
||||||
|
|
||||||
|
DirectedGraph<VertexMarking, EdgeMarking> myGraph = new DirectedGraph<>();
|
||||||
|
|
||||||
|
for (int i = 0; i < 10; i++) {
|
||||||
|
myGraph.addVertex(new MarkedVertex<>(random.nextInt(1, 10)*40, random.nextInt(1, 10)*40, Integer.toString(i), null, Color.BLACK));
|
||||||
|
}
|
||||||
|
|
||||||
|
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());
|
||||||
|
|
||||||
|
drawArea.setCurrentGraph(myGraph);
|
||||||
|
algorithm.setCurrentGraph(myGraph);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
package OurApplication;
|
package OurApplication;
|
||||||
|
|
||||||
import graph.*;
|
import graph.*;
|
||||||
|
import graph.Graph;
|
||||||
import logging.LogElementList;
|
import logging.LogElementList;
|
||||||
import visualisation.DrawArea;
|
import visualisation.DrawArea;
|
||||||
import visualizationElements.*;
|
import visualizationElements.*;
|
||||||
import visualizationElements.Graph;
|
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@ -21,6 +21,8 @@ public class OurDrawArea extends DrawArea{
|
|||||||
|
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private graph.Graph<VertexMarking, EdgeMarking> currentGraph;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard constructor.
|
* Standard constructor.
|
||||||
@ -38,39 +40,37 @@ public class OurDrawArea extends DrawArea{
|
|||||||
super(logList, drawAreaName);
|
super(logList, drawAreaName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void setCurrentGraph(Graph<VertexMarking, EdgeMarking> graph) {
|
||||||
|
this.currentGraph = graph;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draws a visualization element.
|
* Draws a visualization element.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public void draw(Graphics g) {
|
public void draw(Graphics g) {
|
||||||
|
|
||||||
Random random = new Random();
|
this.currentGraph.getScreenGraph().draw(g);
|
||||||
|
|
||||||
DirectedGraph<VertexMarking, EdgeMarking> myGraph = new DirectedGraph<>();
|
OurLogElement logElement = (OurLogElement) logList.get();
|
||||||
|
|
||||||
for (int i = 0; i < 10; i++) {
|
if (logElement.getVertex() != null) {
|
||||||
myGraph.addVertex(new MarkedVertex<>(random.nextInt(1, 10)*35, random.nextInt(1, 10)*35, "", null, Color.BLACK));
|
if (logElement.getVertex().getColor() == Color.BLACK) {
|
||||||
}
|
logElement.getVertex().setColor(Color.YELLOW);
|
||||||
|
} else if (logElement.getVertex().getColor() == Color.YELLOW) {
|
||||||
|
logElement.getVertex().setColor(Color.BLUE);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (logElement.getEdge().getColor() == Color.BLACK) {
|
||||||
|
logElement.getEdge().setColor(Color.YELLOW);
|
||||||
|
} else if (logElement.getEdge().getColor() == Color.YELLOW) {
|
||||||
|
logElement.getEdge().setColor(Color.BLUE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (MarkedVertex<VertexMarking> i: myGraph.getAllVertexes()) {
|
logElement.getVertex().draw(g);
|
||||||
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));
|
|
||||||
|
|
||||||
myGraph.getScreenGraph().draw(g);
|
|
||||||
|
|
||||||
// OurLogElement logElement = (OurLogElement) logList.get();
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,8 @@ import graph.DirectedGraph;
|
|||||||
import graph.EdgeMarking;
|
import graph.EdgeMarking;
|
||||||
import graph.VertexMarking;
|
import graph.VertexMarking;
|
||||||
import logging.LogElement;
|
import logging.LogElement;
|
||||||
|
import visualizationElements.Edge;
|
||||||
|
import visualizationElements.Vertex;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class provides an example for using logging.LogElement.
|
* This class provides an example for using logging.LogElement.
|
||||||
@ -18,7 +20,8 @@ public class OurLogElement extends LogElement{
|
|||||||
|
|
||||||
/** The log elements sum up value. */
|
/** The log elements sum up value. */
|
||||||
protected long value;
|
protected long value;
|
||||||
protected DirectedGraph<VertexMarking, EdgeMarking> ourGraph;
|
protected Vertex vertex;
|
||||||
|
protected Edge edge;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Standard constructor.
|
* Standard constructor.
|
||||||
@ -26,7 +29,7 @@ public class OurLogElement extends LogElement{
|
|||||||
*/
|
*/
|
||||||
public OurLogElement() {
|
public OurLogElement() {
|
||||||
super();
|
super();
|
||||||
value=0;
|
this.value = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -36,11 +39,19 @@ public class OurLogElement extends LogElement{
|
|||||||
* @param description the log element's step description
|
* @param description the log element's step description
|
||||||
* @param value the log element's sum up value
|
* @param value the log element's sum up value
|
||||||
*/
|
*/
|
||||||
public OurLogElement(int step, String description, long value, DirectedGraph<VertexMarking, EdgeMarking> ourGraph){
|
public OurLogElement(int step, String description, long value, Vertex v){
|
||||||
this.step = step;
|
this.step = step;
|
||||||
this.description = description;
|
this.description = description;
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.ourGraph = ourGraph;
|
this.vertex = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public OurLogElement(int step, String description, long value, Edge e){
|
||||||
|
this.step = step;
|
||||||
|
this.description = description;
|
||||||
|
this.value = value;
|
||||||
|
this.edge = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -48,12 +59,16 @@ public class OurLogElement extends LogElement{
|
|||||||
* @return the log element's sum up value
|
* @return the log element's sum up value
|
||||||
*/
|
*/
|
||||||
public long getValue(){
|
public long getValue(){
|
||||||
return value;
|
return this.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DirectedGraph<VertexMarking, EdgeMarking> getGraph(){
|
public Edge getEdge() {
|
||||||
return this.ourGraph;
|
return this.edge;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Vertex getVertex() {
|
||||||
|
return this.vertex;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
package graph;
|
package graph;
|
||||||
|
|
||||||
|
import OurApplication.OurAlgorithm;
|
||||||
|
import OurApplication.OurLogElement;
|
||||||
|
import logging.LogElementList;
|
||||||
import visualizationElements.Edge;
|
import visualizationElements.Edge;
|
||||||
import visualizationElements.EdgeStyle;
|
import visualizationElements.EdgeStyle;
|
||||||
import visualizationElements.Vertex;
|
import visualizationElements.Vertex;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import java.util.PriorityQueue;
|
import java.util.PriorityQueue;
|
||||||
@ -14,18 +18,22 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
|
|||||||
// ATTRIBUTE
|
// ATTRIBUTE
|
||||||
|
|
||||||
private visualizationElements.Graph screenGraph;
|
private visualizationElements.Graph screenGraph;
|
||||||
|
private LogElementList<OurLogElement> logList;
|
||||||
|
|
||||||
|
|
||||||
// KONSTRUKTOREN
|
// KONSTRUKTOREN
|
||||||
|
|
||||||
public DirectedGraph() {
|
public DirectedGraph() {
|
||||||
super();
|
super();
|
||||||
this.screenGraph = new visualizationElements.Graph(new Vector<Vertex>(), new Vector<Edge>(), true, EdgeStyle.Direct);
|
this.screenGraph = new visualizationElements.Graph(new Vector<Vertex>(), new Vector<Edge>(), true, EdgeStyle.Direct);
|
||||||
|
this.logList = new LogElementList<OurLogElement>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public DirectedGraph(String s) {
|
public DirectedGraph(String s) {
|
||||||
super(s);
|
super(s);
|
||||||
this.screenGraph = new visualizationElements.Graph(new Vector<Vertex>(), new Vector<Edge>(), true, EdgeStyle.Direct);
|
this.screenGraph = new visualizationElements.Graph(new Vector<Vertex>(), new Vector<Edge>(), true, EdgeStyle.Direct);
|
||||||
|
this.logList = new LogElementList<OurLogElement>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -36,6 +44,11 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public LogElementList<OurLogElement> getLogList() {
|
||||||
|
return this.logList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// HINZUFÜGEN
|
// HINZUFÜGEN
|
||||||
|
|
||||||
// Kante hinzufügen
|
// Kante hinzufügen
|
||||||
@ -197,6 +210,9 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
|
|||||||
|
|
||||||
// Variable, die Distanz zwischen aktuellem Knoten und Nachfolger speichert
|
// Variable, die Distanz zwischen aktuellem Knoten und Nachfolger speichert
|
||||||
int dist = 0;
|
int dist = 0;
|
||||||
|
// Zähler für LogList
|
||||||
|
int step = 0;
|
||||||
|
visualizationElements.Graph display;
|
||||||
|
|
||||||
while (!queue.isEmpty()) {
|
while (!queue.isEmpty()) {
|
||||||
// Den nächsten Knoten, der am wenigsten kostet, besuchen
|
// Den nächsten Knoten, der am wenigsten kostet, besuchen
|
||||||
@ -206,12 +222,9 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
|
|||||||
visited.put(nextVertex.getElement(), true);
|
visited.put(nextVertex.getElement(), true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
System.out.println("Visit " + nextVertex.getElement().getName());
|
System.out.println("Visit " + nextVertex.getElement().getName());
|
||||||
|
this.logList.add(new OurLogElement(step, "Step: " + step, 0, nextVertex.getElement().getScreenVertex()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Gehe von diesem Knoten aus alle erreichbaren Knoten durch
|
// Gehe von diesem Knoten aus alle erreichbaren Knoten durch
|
||||||
@ -235,21 +248,16 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
|
|||||||
// Aktualisiere Distanz von Start zu nächstem Knoten
|
// Aktualisiere Distanz von Start zu nächstem Knoten
|
||||||
distance.put(i, dist);
|
distance.put(i, dist);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Logging
|
// Logging
|
||||||
System.out.println("Add " + i.getName() + " with " + dist + " weight to queue.");
|
System.out.println("Add " + i.getName() + " with " + dist + " weight to queue.");
|
||||||
|
this.logList.add(new OurLogElement(step, "Step: " + step, 0, nextVertex.getElement().getScreenVertex()));
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Nehme nächsten Knoten in die Queue auf
|
// Nehme nächsten Knoten in die Queue auf
|
||||||
queue.add(new WrapperElement<>(i, dist));
|
queue.add(new WrapperElement<>(i, dist));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("Done");
|
||||||
// Gibt Distanz zu gefragtem Knoten zurück
|
// Gibt Distanz zu gefragtem Knoten zurück
|
||||||
return distance.get(n2);
|
return distance.get(n2);
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,8 @@
|
|||||||
package graph;
|
package graph;
|
||||||
|
|
||||||
|
import OurApplication.OurLogElement;
|
||||||
|
import logging.LogElementList;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
|
public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
|
||||||
@ -42,6 +45,12 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public abstract visualizationElements.Graph getScreenGraph();
|
||||||
|
|
||||||
|
|
||||||
|
public abstract LogElementList<OurLogElement> getLogList();
|
||||||
|
|
||||||
|
|
||||||
// SET-ER
|
// SET-ER
|
||||||
|
|
||||||
public void setName(String s) {
|
public void setName(String s) {
|
||||||
@ -255,4 +264,7 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
|
|||||||
throw new NameDoesNotExistException("One of the Vertexes might not exist");
|
throw new NameDoesNotExistException("One of the Vertexes might not exist");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public abstract int getShortestPathDijkstra(MarkedVertex<T> n1, MarkedVertex<T> n2);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package graph;
|
package graph;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
|
||||||
public class MarkedEdge<U extends EdgeMarking> extends Edge{
|
public class MarkedEdge<U extends EdgeMarking> extends Edge{
|
||||||
|
|
||||||
// ATTRIBUTE
|
// ATTRIBUTE
|
||||||
@ -31,7 +33,7 @@ public class MarkedEdge<U extends EdgeMarking> extends Edge{
|
|||||||
super(s, n1, n2);
|
super(s, n1, n2);
|
||||||
this.marking = u;
|
this.marking = u;
|
||||||
this.weighting = w;
|
this.weighting = w;
|
||||||
this.screenEdge = new visualizationElements.Edge(n1.getScreenVertex(), n2.getScreenVertex(), "u.toString()");
|
this.screenEdge = new visualizationElements.Edge(n1.getScreenVertex(), n2.getScreenVertex(), "u.toString()", Color.BLACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package graph;
|
package graph;
|
||||||
|
|
||||||
|
import OurApplication.OurLogElement;
|
||||||
|
import logging.LogElementList;
|
||||||
import visualizationElements.Edge;
|
import visualizationElements.Edge;
|
||||||
import visualizationElements.EdgeStyle;
|
import visualizationElements.EdgeStyle;
|
||||||
import visualizationElements.Vertex;
|
import visualizationElements.Vertex;
|
||||||
@ -12,6 +14,7 @@ public class UndirectedGraph<T extends VertexMarking, U extends EdgeMarking> ext
|
|||||||
// ATTRIBUTE
|
// ATTRIBUTE
|
||||||
|
|
||||||
private visualizationElements.Graph screenGraph;
|
private visualizationElements.Graph screenGraph;
|
||||||
|
private LogElementList<OurLogElement> logList;
|
||||||
|
|
||||||
|
|
||||||
// KONSTRUKTOREN
|
// KONSTRUKTOREN
|
||||||
@ -19,12 +22,14 @@ public class UndirectedGraph<T extends VertexMarking, U extends EdgeMarking> ext
|
|||||||
public UndirectedGraph() {
|
public UndirectedGraph() {
|
||||||
super();
|
super();
|
||||||
this.screenGraph = new visualizationElements.Graph(new Vector<Vertex>(), new Vector<Edge>(), false, EdgeStyle.Direct);
|
this.screenGraph = new visualizationElements.Graph(new Vector<Vertex>(), new Vector<Edge>(), false, EdgeStyle.Direct);
|
||||||
|
this.logList = new LogElementList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public UndirectedGraph(String s) {
|
public UndirectedGraph(String s) {
|
||||||
super(s);
|
super(s);
|
||||||
this.screenGraph = new visualizationElements.Graph(new Vector<Vertex>(), new Vector<Edge>(), false, EdgeStyle.Direct);
|
this.screenGraph = new visualizationElements.Graph(new Vector<Vertex>(), new Vector<Edge>(), false, EdgeStyle.Direct);
|
||||||
|
this.logList = new LogElementList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -35,6 +40,11 @@ public class UndirectedGraph<T extends VertexMarking, U extends EdgeMarking> ext
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public LogElementList<OurLogElement> getLogList() {
|
||||||
|
return this.logList;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// HINZUFÜGEN
|
// HINZUFÜGEN
|
||||||
|
|
||||||
// Kante hinzufügen
|
// Kante hinzufügen
|
||||||
@ -107,4 +117,9 @@ public class UndirectedGraph<T extends VertexMarking, U extends EdgeMarking> ext
|
|||||||
return neighbours;
|
return neighbours;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getShortestPathDijkstra(MarkedVertex<T> n1, MarkedVertex<T> n2) {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user