Stable Version with finished visualisation
This commit is contained in:
parent
58ed89d78c
commit
bed270e7d2
53
.idea/workspace.xml
generated
53
.idea/workspace.xml
generated
@ -6,13 +6,17 @@
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="70f8ea87-9ffc-471a-8059-ebbfc323adcc" name="Changes" comment="Adding AStar Algorithm">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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/OurLogElement.java" beforeDir="false" afterPath="$PROJECT_DIR$/OurApplication/OurLogElement.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/Graph.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/Graph.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/graph/UndirectedGraph.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/UndirectedGraph.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurAlgorithm.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurAlgorithm.class" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/graph/Display.java" beforeDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurApplication.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurApplication.class" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurDrawArea.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurDrawArea.class" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurLogElement.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurLogElement.class" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/graph/DirectedGraph.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/graph/DirectedGraph.class" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/graph/Graph.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/graph/Graph.class" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/graph/UndirectedGraph.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/graph/UndirectedGraph.class" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/graph/Display.class" beforeDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -32,16 +36,16 @@
|
||||
<option name="hideEmptyMiddlePackages" value="true" />
|
||||
<option name="showLibraryContents" value="true" />
|
||||
</component>
|
||||
<component name="PropertiesComponent"><![CDATA[{
|
||||
"keyToString": {
|
||||
"Application.Display.executor": "Run",
|
||||
"Application.OurApplication.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"git-widget-placeholder": "main",
|
||||
"kotlin-language-version-configured": "true",
|
||||
"last_opened_file_path": "C:/Git/ProjektGraphMain"
|
||||
<component name="PropertiesComponent">{
|
||||
"keyToString": {
|
||||
"Application.Display.executor": "Run",
|
||||
"Application.OurApplication.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"git-widget-placeholder": "main",
|
||||
"kotlin-language-version-configured": "true",
|
||||
"last_opened_file_path": "C:/Git/ProjektGraphMain"
|
||||
}
|
||||
}]]></component>
|
||||
}</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="CopyFile.RECENT_KEYS">
|
||||
<recent name="C:\Git\ProjektGraph" />
|
||||
@ -84,7 +88,15 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1720036227325</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="4" />
|
||||
<task id="LOCAL-00004" summary="Adding AStar Algorithm">
|
||||
<option name="closed" value="true" />
|
||||
<created>1720042374225</created>
|
||||
<option name="number" value="00004" />
|
||||
<option name="presentableId" value="LOCAL-00004" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1720042374225</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="5" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
@ -103,4 +115,15 @@
|
||||
<MESSAGE value="Adding AStar Algorithm" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Adding AStar Algorithm" />
|
||||
</component>
|
||||
<component name="XDebuggerManager">
|
||||
<breakpoint-manager>
|
||||
<breakpoints>
|
||||
<line-breakpoint enabled="true" type="java-line">
|
||||
<url>file://$PROJECT_DIR$/OurApplication/OurDrawArea.java</url>
|
||||
<line>53</line>
|
||||
<option name="timeStamp" value="3" />
|
||||
</line-breakpoint>
|
||||
</breakpoints>
|
||||
</breakpoint-manager>
|
||||
</component>
|
||||
</project>
|
@ -79,7 +79,7 @@ public class OurApplication {
|
||||
|
||||
System.out.println(myGraph.toString());
|
||||
|
||||
drawArea.setCurrentGraph(myGraph);
|
||||
drawArea.setCurrentGraph(myGraph.getScreenGraph());
|
||||
algorithm.setCurrentGraph(myGraph);
|
||||
|
||||
}
|
||||
|
@ -21,7 +21,7 @@ public class OurDrawArea extends DrawArea{
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private graph.Graph<VertexMarking, EdgeMarking> currentGraph;
|
||||
private visualizationElements.Graph currentGraph;
|
||||
|
||||
|
||||
/**
|
||||
@ -41,7 +41,7 @@ public class OurDrawArea extends DrawArea{
|
||||
}
|
||||
|
||||
|
||||
public void setCurrentGraph(Graph<VertexMarking, EdgeMarking> graph) {
|
||||
public void setCurrentGraph(visualizationElements.Graph graph) {
|
||||
this.currentGraph = graph;
|
||||
}
|
||||
|
||||
@ -51,25 +51,8 @@ public class OurDrawArea extends DrawArea{
|
||||
|
||||
public void draw(Graphics g) {
|
||||
|
||||
this.currentGraph.getScreenGraph().draw(g);
|
||||
|
||||
OurLogElement logElement = (OurLogElement) logList.get();
|
||||
|
||||
if (logElement.getVertex() != null) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
logElement.getVertex().draw(g);
|
||||
logElement.getGraph().draw(g);
|
||||
|
||||
}
|
||||
|
||||
|
@ -22,6 +22,7 @@ public class OurLogElement extends LogElement{
|
||||
protected long value;
|
||||
protected Vertex vertex;
|
||||
protected Edge edge;
|
||||
protected visualizationElements.Graph ourGraph;
|
||||
|
||||
/**
|
||||
* Standard constructor.
|
||||
@ -47,6 +48,7 @@ public class OurLogElement extends LogElement{
|
||||
}
|
||||
|
||||
|
||||
|
||||
public OurLogElement(int step, String description, long value, Edge e){
|
||||
this.step = step;
|
||||
this.description = description;
|
||||
@ -54,6 +56,13 @@ public class OurLogElement extends LogElement{
|
||||
this.edge = e;
|
||||
}
|
||||
|
||||
public OurLogElement(int step, String description, long value, visualizationElements.Graph ourGraph ){
|
||||
this.step = step;
|
||||
this.description = description;
|
||||
this.value = value;
|
||||
this.ourGraph = ourGraph;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the log element's sum up value.
|
||||
* @return the log element's sum up value
|
||||
@ -71,4 +80,9 @@ public class OurLogElement extends LogElement{
|
||||
public Vertex getVertex() {
|
||||
return this.vertex;
|
||||
}
|
||||
|
||||
|
||||
public visualizationElements.Graph getGraph() {
|
||||
return this.ourGraph;
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import visualizationElements.EdgeStyle;
|
||||
import visualizationElements.Vertex;
|
||||
|
||||
import java.awt.*;
|
||||
import java.io.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
import java.util.PriorityQueue;
|
||||
@ -43,6 +44,23 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
|
||||
return this.screenGraph;
|
||||
}
|
||||
|
||||
public visualizationElements.Graph getScreenGraphCopy() {
|
||||
visualizationElements.Graph graphCopy = new visualizationElements.Graph(new Vector<Vertex>(), new Vector<Edge>(), true, EdgeStyle.Direct);
|
||||
Vector<visualizationElements.Vertex> copiedVertexes = new Vector<>();
|
||||
Vector<visualizationElements.Edge> copiedEdges = new Vector<>();
|
||||
for (visualizationElements.Vertex vertexCopy : this.screenGraph.getVertexes()) {
|
||||
visualizationElements.Vertex newCopiedVertex = new visualizationElements.Vertex(vertexCopy.getXpos(), vertexCopy.getYpos(), vertexCopy.getMarking(), vertexCopy.getColor());
|
||||
copiedVertexes.add(newCopiedVertex);
|
||||
graphCopy.setVertexes(copiedVertexes);
|
||||
}
|
||||
for (visualizationElements.Edge edgeCopy : this.screenGraph.getEdges()) {
|
||||
visualizationElements.Edge newCopiedEdge = new visualizationElements.Edge(edgeCopy.getSource(), edgeCopy.getDestination(), edgeCopy.getMarking(), edgeCopy.getColor());
|
||||
copiedEdges.add(newCopiedEdge);
|
||||
graphCopy.setEdges(copiedEdges);
|
||||
}
|
||||
return graphCopy;
|
||||
}
|
||||
|
||||
|
||||
public LogElementList<OurLogElement> getLogList() {
|
||||
return this.logList;
|
||||
@ -212,7 +230,6 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
|
||||
int dist = 0;
|
||||
// Zähler für LogList
|
||||
int step = 0;
|
||||
visualizationElements.Graph display;
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
// Den nächsten Knoten, der am wenigsten kostet, besuchen
|
||||
@ -224,7 +241,8 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
|
||||
|
||||
// Logging
|
||||
System.out.println("Visit " + nextVertex.getElement().getName());
|
||||
this.logList.add(new OurLogElement(step, "Step: " + step, 0, nextVertex.getElement().getScreenVertex()));
|
||||
nextVertex.getElement().getScreenVertex().setColor(Color.BLUE);
|
||||
this.logList.add(new OurLogElement(step, "Step: " + step, 0, this.getScreenGraphCopy()));
|
||||
|
||||
|
||||
// Gehe von diesem Knoten aus alle erreichbaren Knoten durch
|
||||
@ -250,7 +268,8 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
|
||||
|
||||
// Logging
|
||||
System.out.println("Add " + i.getName() + " with " + dist + " weight to queue.");
|
||||
this.logList.add(new OurLogElement(step, "Step: " + step, 0, nextVertex.getElement().getScreenVertex()));
|
||||
nextVertex.getElement().getScreenVertex().setColor(Color.YELLOW);
|
||||
this.logList.add(new OurLogElement(step, "Step: " + step, 0, this.getScreenGraphCopy()));
|
||||
|
||||
// Nehme nächsten Knoten in die Queue auf
|
||||
queue.add(new WrapperElement<>(i, dist));
|
||||
@ -288,7 +307,6 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
|
||||
int airDist = 0;
|
||||
// Zähler für LogList
|
||||
int step = 0;
|
||||
visualizationElements.Graph display;
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
// Den nächsten Knoten, der am wenigsten kostet, besuchen
|
||||
@ -300,7 +318,8 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
|
||||
|
||||
// Logging
|
||||
System.out.println("Visit " + nextVertex.getElement().getName());
|
||||
this.logList.add(new OurLogElement(step, "Step: " + step, 0, nextVertex.getElement().getScreenVertex()));
|
||||
nextVertex.getElement().getScreenVertex().setColor(Color.BLUE);
|
||||
this.logList.add(new OurLogElement(step, "Step: " + step, 0, this.getScreenGraphCopy()));
|
||||
|
||||
|
||||
// Gehe von diesem Knoten aus alle erreichbaren Knoten durch
|
||||
@ -330,7 +349,8 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
|
||||
|
||||
// Logging
|
||||
System.out.println("Add " + i.getName() + " with " + dist + " weight to queue.");
|
||||
this.logList.add(new OurLogElement(step, "Step: " + step, 0, nextVertex.getElement().getScreenVertex()));
|
||||
nextVertex.getElement().getScreenVertex().setColor(Color.YELLOW);
|
||||
this.logList.add(new OurLogElement(step, "Step: " + step, 0, this.getScreenGraphCopy()));
|
||||
|
||||
// Nehme nächsten Knoten in die Queue auf
|
||||
queue.add(new WrapperElement<>(i, dist));
|
||||
|
@ -1,32 +0,0 @@
|
||||
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));
|
||||
|
||||
}
|
||||
}
|
46
out/production/ProjektGraph/.idea/workspace.xml
generated
46
out/production/ProjektGraph/.idea/workspace.xml
generated
@ -4,11 +4,10 @@
|
||||
<option name="autoReloadType" value="SELECTIVE" />
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="70f8ea87-9ffc-471a-8059-ebbfc323adcc" name="Changes" comment="">
|
||||
<list default="true" id="70f8ea87-9ffc-471a-8059-ebbfc323adcc" name="Changes" comment="Adding AStar Algorithm">
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" 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$/graph/MarkedEdge.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/MarkedEdge.java" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/graph/Display.java" beforeDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@ -17,6 +16,7 @@
|
||||
</component>
|
||||
<component name="Git.Settings">
|
||||
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
|
||||
<option name="RESET_MODE" value="HARD" />
|
||||
</component>
|
||||
<component name="ProjectColorInfo">{
|
||||
"associatedIndex": 2
|
||||
@ -32,7 +32,7 @@
|
||||
"Application.Display.executor": "Run",
|
||||
"Application.OurApplication.executor": "Run",
|
||||
"RunOnceActivity.ShowReadmeOnStart": "true",
|
||||
"git-widget-placeholder": "Versuch__Christian",
|
||||
"git-widget-placeholder": "main",
|
||||
"kotlin-language-version-configured": "true",
|
||||
"last_opened_file_path": "C:/Git/ProjektGraphMain"
|
||||
}
|
||||
@ -55,6 +55,39 @@
|
||||
<option name="presentableId" value="Default" />
|
||||
<updated>1718547365327</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="Stable Version 3.0">
|
||||
<option name="closed" value="true" />
|
||||
<created>1720028543313</created>
|
||||
<option name="number" value="00001" />
|
||||
<option name="presentableId" value="LOCAL-00001" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1720028543313</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00002" summary="Adding AStar Algorithm">
|
||||
<option name="closed" value="true" />
|
||||
<created>1720036191925</created>
|
||||
<option name="number" value="00002" />
|
||||
<option name="presentableId" value="LOCAL-00002" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1720036191926</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00003" summary="Adding AStar Algorithm">
|
||||
<option name="closed" value="true" />
|
||||
<created>1720036227325</created>
|
||||
<option name="number" value="00003" />
|
||||
<option name="presentableId" value="LOCAL-00003" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1720036227325</updated>
|
||||
</task>
|
||||
<task id="LOCAL-00004" summary="Adding AStar Algorithm">
|
||||
<option name="closed" value="true" />
|
||||
<created>1720042374225</created>
|
||||
<option name="number" value="00004" />
|
||||
<option name="presentableId" value="LOCAL-00004" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1720042374225</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="5" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="Vcs.Log.Tabs.Properties">
|
||||
@ -68,4 +101,9 @@
|
||||
</map>
|
||||
</option>
|
||||
</component>
|
||||
<component name="VcsManagerConfiguration">
|
||||
<MESSAGE value="Stable Version 3.0" />
|
||||
<MESSAGE value="Adding AStar Algorithm" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="Adding AStar Algorithm" />
|
||||
</component>
|
||||
</project>
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue
Block a user