Java Doc für graph fertig

This commit is contained in:
cmerkens 2024-07-08 00:11:04 +02:00
parent 80d48d5335
commit d4e913b5e2
10 changed files with 181 additions and 77 deletions

12
.idea/workspace.xml generated
View File

@ -5,16 +5,16 @@
</component> </component>
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="70f8ea87-9ffc-471a-8059-ebbfc323adcc" name="Changes" comment="LegendArea gestaltet"> <list default="true" id="70f8ea87-9ffc-471a-8059-ebbfc323adcc" name="Changes" comment="LegendArea gestaltet">
<change afterPath="$PROJECT_DIR$/graph/EdgeWeightMarking.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <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/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/EdgeMarking.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/EdgeMarking.java" afterDir="false" /> <change beforePath="$PROJECT_DIR$/graph/EdgeMarking.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/EdgeMarking.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/graph/EdgeWeightMarking.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/EdgeWeightMarking.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/MarkedVertex.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/MarkedVertex.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/graph/NameDoesNotExistException.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/NameDoesNotExistException.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$/out/production/ProjektGraph/OurApplication/OurApplication.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurApplication.class" afterDir="false" /> <change beforePath="$PROJECT_DIR$/graph/VertexMarking.java" beforeDir="false" afterPath="$PROJECT_DIR$/graph/VertexMarking.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurParameterArea.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/OurApplication/OurParameterArea.class" afterDir="false" />
<change beforePath="$PROJECT_DIR$/out/production/ProjektGraph/graph/EdgeWeightMarking.class" beforeDir="false" afterPath="$PROJECT_DIR$/out/production/ProjektGraph/graph/EdgeWeightMarking.class" 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" />

View File

@ -12,6 +12,14 @@ import java.util.Objects;
import java.util.PriorityQueue; import java.util.PriorityQueue;
import java.util.Vector; import java.util.Vector;
/**
* Represents a directed graph with vertex and edge markings. This class extends the Graph class and
* provides additional functionality for directed graphs, including visualization and logging capabilities.
*
* @param <T> the type of vertex marking
* @param <U> the type of edge marking
*/
public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> extends Graph<T, U> { public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> extends Graph<T, U> {
// ATTRIBUTE // ATTRIBUTE
@ -22,6 +30,9 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
// KONSTRUKTOREN // KONSTRUKTOREN
/**
* Constructs an empty directed graph.
*/
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);
@ -29,6 +40,11 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
} }
/**
* Constructs a directed graph from a string representation.
*
* @param s the string representation of the graph
*/
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);
@ -38,10 +54,21 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
// GET-ER // GET-ER
/**
* Returns the screen graph associated with this directed graph.
*
* @return the screen graph
*/
public visualizationElements.Graph getScreenGraph() { public visualizationElements.Graph getScreenGraph() {
return this.screenGraph; return this.screenGraph;
} }
/**
* Returns a copy of the screen graph associated with this directed graph.
*
* @return a copy of the screen graph
*/
public visualizationElements.Graph getScreenGraphCopy() { public visualizationElements.Graph getScreenGraphCopy() {
visualizationElements.Graph graphCopy = new visualizationElements.Graph(new Vector<Vertex>(), new Vector<Edge>(), true, EdgeStyle.Direct); visualizationElements.Graph graphCopy = new visualizationElements.Graph(new Vector<Vertex>(), new Vector<Edge>(), true, EdgeStyle.Direct);
Vector<visualizationElements.Vertex> copiedVertexes = new Vector<>(); Vector<visualizationElements.Vertex> copiedVertexes = new Vector<>();
@ -60,6 +87,11 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
} }
/**
* Returns the log list associated with this directed graph.
*
* @return the log list
*/
public LogElementList<OurLogElement> getLogList() { public LogElementList<OurLogElement> getLogList() {
return this.logList; return this.logList;
} }
@ -67,14 +99,22 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
// HINZUFÜGEN // HINZUFÜGEN
// Kante hinzufügen /**
* Adds an edge to the graph.
*
* @param e the edge to be added
*/
public void addEdge(MarkedEdge<U> e) { public void addEdge(MarkedEdge<U> e) {
super.addEdge(e); super.addEdge(e);
this.screenGraph.getEdges().add(e.getScreenEdge()); this.screenGraph.getEdges().add(e.getScreenEdge());
} }
// Knoten hinzufügen /**
* Adds a vertex to the graph.
*
* @param n the vertex to be added
*/
public void addVertex(MarkedVertex<T> n) { public void addVertex(MarkedVertex<T> n) {
super.addVertex(n); super.addVertex(n);
this.screenGraph.getVertexes().add(n.getScreenVertex()); this.screenGraph.getVertexes().add(n.getScreenVertex());
@ -83,14 +123,22 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
// LÖSCHEN // LÖSCHEN
// Kante löschen /**
* Removes an edge from the graph.
*
* @param e the edge to be removed
*/
public void removeEdge(MarkedEdge<U> e) { public void removeEdge(MarkedEdge<U> e) {
super.removeEdge(e); super.removeEdge(e);
this.screenGraph.getEdges().remove(e.getScreenEdge()); this.screenGraph.getEdges().remove(e.getScreenEdge());
} }
// Knoten löschen /**
* Removes a vertex from the graph.
*
* @param n the vertex to be removed
*/
public void removeVertex(MarkedVertex<T> n) { public void removeVertex(MarkedVertex<T> n) {
super.removeVertex(n); super.removeVertex(n);
this.screenGraph.getVertexes().remove(n.getScreenVertex()); this.screenGraph.getVertexes().remove(n.getScreenVertex());
@ -99,7 +147,13 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
// KNOTEN EIGENSCHAFTEN // KNOTEN EIGENSCHAFTEN
// Prüfung, ob zwei Knoten stark adjazent sind /**
* Checks if two vertices are strongly adjacent (i.e., there is a bidirectional edge between them).
*
* @param n1 the first vertex
* @param n2 the second vertex
* @return true if the vertices are strongly adjacent, false otherwise
*/
public boolean areStrongAdjacent(MarkedVertex<T> n1, MarkedVertex<T> n2) { public boolean areStrongAdjacent(MarkedVertex<T> n1, MarkedVertex<T> n2) {
boolean n1ton2 = false; boolean n1ton2 = false;
boolean n2ton1 = false; boolean n2ton1 = false;
@ -114,6 +168,14 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
} }
/**
* Checks if two vertices are strongly adjacent (i.e., there is a bidirectional edge between them) by their names.
*
* @param s1 the name of the first vertex
* @param s2 the name of the second vertex
* @return true if the vertices are strongly adjacent, false otherwise
* @throws NameDoesNotExistException if one of the vertices does not exist
*/
public boolean areStrongAdjacent(String s1, String s2) throws NameDoesNotExistException { public boolean areStrongAdjacent(String s1, String s2) throws NameDoesNotExistException {
MarkedVertex<T> n1 = null; MarkedVertex<T> n1 = null;
MarkedVertex<T> n2 = null; MarkedVertex<T> n2 = null;
@ -132,7 +194,12 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
} }
// Prüfung des Eingangsgrades eines Knotens /**
* Returns the in-degree of a vertex (i.e., the number of edges directed towards the vertex).
*
* @param n the vertex
* @return the in-degree of the vertex
*/
public int inDegree(MarkedVertex<T> n) { public int inDegree(MarkedVertex<T> n) {
int degree = 0; int degree = 0;
for (MarkedEdge<U> i: this.getAllEdges()) { for (MarkedEdge<U> i: this.getAllEdges()) {
@ -144,6 +211,13 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
} }
/**
* Returns the in-degree of a vertex by its name.
*
* @param s the name of the vertex
* @return the in-degree of the vertex
* @throws NameDoesNotExistException if the vertex does not exist
*/
public int inDegree(String s) throws NameDoesNotExistException{ public int inDegree(String s) throws NameDoesNotExistException{
for (MarkedVertex<T> i: this.getAllVertexes()) { for (MarkedVertex<T> i: this.getAllVertexes()) {
if (Objects.equals(i.getName(), s)) { if (Objects.equals(i.getName(), s)) {
@ -154,7 +228,12 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
} }
// Prüfung des Ausgangsgrades eines Knotens /**
* Returns the out-degree of a vertex (i.e., the number of edges directed away from the vertex).
*
* @param n the vertex
* @return the out-degree of the vertex
*/
public int outDegree(MarkedVertex<T> n) { public int outDegree(MarkedVertex<T> n) {
int degree = 0; int degree = 0;
for (MarkedEdge<U> i: this.getAllEdges()) { for (MarkedEdge<U> i: this.getAllEdges()) {
@ -166,6 +245,13 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
} }
/**
* Returns the out-degree of a vertex by its name.
*
* @param s the name of the vertex
* @return the out-degree of the vertex
* @throws NameDoesNotExistException if the vertex does not exist
*/
public int outDegree(String s) throws NameDoesNotExistException{ public int outDegree(String s) throws NameDoesNotExistException{
for (MarkedVertex<T> i: this.getAllVertexes()) { for (MarkedVertex<T> i: this.getAllVertexes()) {
if (Objects.equals(i.getName(), s)) { if (Objects.equals(i.getName(), s)) {
@ -176,7 +262,12 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
} }
// Prüfung, welche Knoten Vorgänger sind /**
* Returns a vector of predecessor vertices (i.e., vertices with edges directed towards the specified vertex).
*
* @param n the vertex
* @return a vector of predecessor vertices
*/
public Vector<MarkedVertex<T>> getPredecessors(MarkedVertex<T> n) { public Vector<MarkedVertex<T>> getPredecessors(MarkedVertex<T> n) {
Vector<MarkedVertex<T>> predecessors = new Vector<>(); Vector<MarkedVertex<T>> predecessors = new Vector<>();
for (MarkedEdge<U> i: this.getAllEdges()) { for (MarkedEdge<U> i: this.getAllEdges()) {
@ -188,7 +279,12 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
} }
// Prüfung, welche Knoten Nachfolger sind /**
* Returns a vector of successor vertices (i.e., vertices with edges directed away from the specified vertex).
*
* @param n the vertex
* @return a vector of successor vertices
*/
public Vector<MarkedVertex<T>> getSuccessors(MarkedVertex<T> n) { public Vector<MarkedVertex<T>> getSuccessors(MarkedVertex<T> n) {
Vector<MarkedVertex<T>> successors = new Vector<>(); Vector<MarkedVertex<T>> successors = new Vector<>();
for (MarkedEdge<U> i: this.getAllEdges()) { for (MarkedEdge<U> i: this.getAllEdges()) {
@ -202,7 +298,13 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
// AUFGABE 2 // AUFGABE 2
// Dijkstra-Algorithmus /**
* Finds the shortest path between two vertices using Dijkstra's algorithm.
*
* @param n1 the starting vertex
* @param n2 the ending vertex
* @return the shortest distance from n1 to n2, or -1 if no path is found
*/
public int getShortestPathDijkstra(MarkedVertex<T> n1, MarkedVertex<T> n2) { public int getShortestPathDijkstra(MarkedVertex<T> n1, MarkedVertex<T> n2) {
// Erstellt Hashmap um Distanz von Startnoten zu jedem Knoten auf dem Graph zu tracken // Erstellt Hashmap um Distanz von Startnoten zu jedem Knoten auf dem Graph zu tracken
@ -336,7 +438,13 @@ public class DirectedGraph<T extends VertexMarking, U extends EdgeMarking> exten
} }
/**
* Finds the shortest path between two vertices using the A* algorithm.
*
* @param n1 the starting vertex
* @param n2 the ending vertex
* @return the shortest distance from n1 to n2, or -1 if no path is found
*/
public int getShortestPathAStar(MarkedVertex<T> n1, MarkedVertex<T> n2) { public int getShortestPathAStar(MarkedVertex<T> n1, MarkedVertex<T> n2) {
// Erstellt Hashmap um Distanz von Startnoten zu jedem Knoten auf dem Graph zu tracken // Erstellt Hashmap um Distanz von Startnoten zu jedem Knoten auf dem Graph zu tracken

View File

@ -6,40 +6,3 @@ package graph;
*/ */
public abstract class EdgeMarking extends Marking { public abstract class EdgeMarking extends Marking {
} }
/**
* Class representing a specific type of edge marking: edge weight.
* Inherits from EdgeMarking.
*/
class EdgeWeightMarking extends EdgeMarking {
/** The weight value associated with this edge marking. */
private int weight;
/**
* Constructor to initialize the EdgeWeightMarking with a specified weight.
*
* @param weight The weight value to set.
*/
EdgeWeightMarking(int weight) {
this.weight = weight;
}
/**
* Sets the weight value of this edge marking.
*
* @param weight The weight value to set.
*/
public void setWeight(int weight) {
this.weight = weight;
}
/**
* Retrieves the weight value of this edge marking.
*
* @return The weight value of this edge marking.
*/
public int getWeight() {
return this.weight;
}
}

View File

@ -1,16 +1,38 @@
package graph; package graph;
/**
* Class representing a specific type of edge marking: edge weight.
* Inherits from EdgeMarking.
*/
public class EdgeWeightMarking extends EdgeMarking { public class EdgeWeightMarking extends EdgeMarking {
/** The weight value associated with this edge marking. */
private int weight; private int weight;
public EdgeWeightMarking(int weight){ /**
* Constructor to initialize the EdgeWeightMarking with a specified weight.
*
* @param weight The weight value to set.
*/
public EdgeWeightMarking(int weight) {
this.weight = weight; this.weight = weight;
} }
public void setWeight(int weight){ /**
this.weight=weight; * Sets the weight value of this edge marking.
*
* @param weight The weight value to set.
*/
public void setWeight(int weight) {
this.weight = weight;
} }
public int getWeight(){
/**
* Retrieves the weight value of this edge marking.
*
* @return The weight value of this edge marking.
*/
public int getWeight() {
return this.weight; return this.weight;
} }
} }

View File

@ -35,6 +35,7 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
this.vertexes = new Vector<>(); this.vertexes = new Vector<>();
} }
/** /**
* Constructor that initializes the graph with a given name. * Constructor that initializes the graph with a given name.
* @param s The name of the graph. * @param s The name of the graph.
@ -55,6 +56,7 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
return this.name; return this.name;
} }
/** /**
* Returns all edges in the graph. * Returns all edges in the graph.
* @return Vector containing all edges in the graph. * @return Vector containing all edges in the graph.
@ -63,6 +65,7 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
return this.edges; return this.edges;
} }
/** /**
* Returns all vertices in the graph. * Returns all vertices in the graph.
* @return Vector containing all vertices in the graph. * @return Vector containing all vertices in the graph.
@ -71,12 +74,14 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
return this.vertexes; return this.vertexes;
} }
/** /**
* Abstract method to get the visualization representation of the graph. * Abstract method to get the visualization representation of the graph.
* @return Visualization representation of the graph. * @return Visualization representation of the graph.
*/ */
public abstract visualizationElements.Graph getScreenGraph(); public abstract visualizationElements.Graph getScreenGraph();
/** /**
* Abstract method to get the log list associated with the graph. * Abstract method to get the log list associated with the graph.
* @return LogElementList containing log elements associated with the graph. * @return LogElementList containing log elements associated with the graph.
@ -95,7 +100,6 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
} }
// Ausgabe
/** /**
* Returns a string representation of the graph. * Returns a string representation of the graph.
* @return String representation of the graph. * @return String representation of the graph.
@ -116,7 +120,6 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
// HINZUFÜGEN // HINZUFÜGEN
// Kante hinzufügen
/** /**
* Adds an edge to the graph. * Adds an edge to the graph.
* @param e The edge to add. * @param e The edge to add.
@ -126,7 +129,6 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
} }
// Knoten hinzufügen
/** /**
* Adds a vertex to the graph. * Adds a vertex to the graph.
* @param n The vertex to add. * @param n The vertex to add.
@ -138,7 +140,6 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
// LÖSCHEN // LÖSCHEN
// Kante löschen
/** /**
* Removes an edge from the graph. * Removes an edge from the graph.
* @param e The edge to remove. * @param e The edge to remove.
@ -147,6 +148,7 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
this.edges.remove(e); this.edges.remove(e);
} }
/** /**
* Removes an edge from the graph based on its name. * Removes an edge from the graph based on its name.
* @param s The name of the edge to remove. * @param s The name of the edge to remove.
@ -163,7 +165,6 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
} }
// Knoten löschen
/** /**
* Removes a vertex from the graph. * Removes a vertex from the graph.
* @param n The vertex to remove. * @param n The vertex to remove.
@ -177,6 +178,7 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
this.vertexes.remove(n); this.vertexes.remove(n);
} }
/** /**
* Removes a vertex from the graph based on its name. * Removes a vertex from the graph based on its name.
* @param s The name of the vertex to remove. * @param s The name of the vertex to remove.
@ -195,7 +197,6 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
// GRAPH EIGENSCHAFTEN // GRAPH EIGENSCHAFTEN
// Kantenmenge
/** /**
* Returns the number of edges in the graph. * Returns the number of edges in the graph.
* @return The number of edges in the graph. * @return The number of edges in the graph.
@ -205,7 +206,6 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
} }
// Knotenmenge
/** /**
* Returns the number of vertices in the graph. * Returns the number of vertices in the graph.
* @return The number of vertices in the graph. * @return The number of vertices in the graph.
@ -215,7 +215,6 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
} }
// Grad des Graphen
/** /**
* Computes and returns the degree of the graph. * Computes and returns the degree of the graph.
* @return The degree of the graph. * @return The degree of the graph.
@ -225,7 +224,6 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
} }
// Prüfung, ob Knoten im Graph
/** /**
* Checks if a vertex is present in the graph. * Checks if a vertex is present in the graph.
* @param n The vertex to check. * @param n The vertex to check.
@ -250,7 +248,6 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
} }
// Prüfung, ob Kante im Graph
/** /**
* Checks if an edge is present in the graph. * Checks if an edge is present in the graph.
* @param e The edge to check. * @param e The edge to check.
@ -277,7 +274,6 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
// KNOTEN EIGENSCHAFTEN // KNOTEN EIGENSCHAFTEN
// Prüfung, ob Kante zwischen zwei Knoten
/** /**
* Checks if there is an edge between two vertices in the graph. * Checks if there is an edge between two vertices in the graph.
* @param v1 First vertex. * @param v1 First vertex.
@ -293,6 +289,7 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
return false; return false;
} }
/** /**
* Checks if there is an edge between two vertices identified by their names. * Checks if there is an edge between two vertices identified by their names.
* @param s1 Name of the first vertex. * @param s1 Name of the first vertex.
@ -318,7 +315,6 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
} }
// Prüfung, ob zwei Knoten adjazent sind
/** /**
* Checks if two vertices are adjacent (connected by an edge) in the graph. * Checks if two vertices are adjacent (connected by an edge) in the graph.
* @param n1 First vertex. * @param n1 First vertex.
@ -334,6 +330,7 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
return false; return false;
} }
/** /**
* Checks if two vertices identified by their names are adjacent (connected by an edge) in the graph. * Checks if two vertices identified by their names are adjacent (connected by an edge) in the graph.
* @param s1 Name of the first vertex. * @param s1 Name of the first vertex.
@ -359,7 +356,6 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
} }
// Prüfung, ob Knoten eine Schlinge besitzt
/** /**
* Checks if a vertex has a loop (an edge connecting it to itself) in the graph. * Checks if a vertex has a loop (an edge connecting it to itself) in the graph.
* @param n The vertex to check. * @param n The vertex to check.
@ -374,6 +370,7 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
return false; return false;
} }
/** /**
* Checks if a vertex identified by its name has a loop (an edge connecting it to itself) in the graph. * Checks if a vertex identified by its name has a loop (an edge connecting it to itself) in the graph.
* @param s The name of the vertex to check. * @param s The name of the vertex to check.
@ -390,7 +387,6 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
} }
// Methode für das Zurücksetzten der Knotenfarben
/** /**
* Resets the screen graph colors of all vertices to black. * Resets the screen graph colors of all vertices to black.
*/ */
@ -400,6 +396,7 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
} }
} }
/** /**
* Abstract method to find the shortest path between two vertices using Dijkstra's algorithm. * Abstract method to find the shortest path between two vertices using Dijkstra's algorithm.
* @param n1 Starting vertex. * @param n1 Starting vertex.
@ -408,6 +405,7 @@ public abstract class Graph<T extends VertexMarking, U extends EdgeMarking> {
*/ */
public abstract int getShortestPathDijkstra(MarkedVertex<T> n1, MarkedVertex<T> n2); public abstract int getShortestPathDijkstra(MarkedVertex<T> n1, MarkedVertex<T> n2);
/** /**
* Abstract method to find the shortest path between two vertices using A* algorithm. * Abstract method to find the shortest path between two vertices using A* algorithm.
* @param n1 Starting vertex. * @param n1 Starting vertex.

View File

@ -16,6 +16,7 @@ public class MarkedEdge<U extends EdgeMarking> extends Edge {
private U marking; private U marking;
private visualizationElements.Edge screenEdge; private visualizationElements.Edge screenEdge;
// CONSTRUCTORS // CONSTRUCTORS
/** /**
@ -26,6 +27,7 @@ public class MarkedEdge<U extends EdgeMarking> extends Edge {
this.screenEdge = new visualizationElements.Edge(null, null); this.screenEdge = new visualizationElements.Edge(null, null);
} }
/** /**
* Constructor initializes the edge with a name, vertices, and marking. * Constructor initializes the edge with a name, vertices, and marking.
* *
@ -45,6 +47,7 @@ public class MarkedEdge<U extends EdgeMarking> extends Edge {
Color.BLACK); Color.BLACK);
} }
// GETTERS // GETTERS
/** /**
@ -65,6 +68,7 @@ public class MarkedEdge<U extends EdgeMarking> extends Edge {
return this.screenEdge; return this.screenEdge;
} }
// SETTERS // SETTERS
/** /**
@ -78,6 +82,7 @@ public class MarkedEdge<U extends EdgeMarking> extends Edge {
this.screenEdge.setMarking(Integer.toString(m.getWeight())); this.screenEdge.setMarking(Integer.toString(m.getWeight()));
} }
// OUTPUT // OUTPUT
/** /**

View File

@ -19,6 +19,7 @@ public class MarkedVertex<T extends VertexMarking> extends Vertex {
private int yCord; private int yCord;
private visualizationElements.Vertex screenVertex; private visualizationElements.Vertex screenVertex;
// CONSTRUCTORS // CONSTRUCTORS
/** /**
@ -31,6 +32,7 @@ public class MarkedVertex<T extends VertexMarking> extends Vertex {
this.yCord = 0; this.yCord = 0;
} }
/** /**
* Constructor initializes the vertex with a name and marking. * Constructor initializes the vertex with a name and marking.
* *
@ -45,6 +47,7 @@ public class MarkedVertex<T extends VertexMarking> extends Vertex {
this.yCord = 0; this.yCord = 0;
} }
/** /**
* Constructor initializes the vertex with coordinates, name, marking, and color. * Constructor initializes the vertex with coordinates, name, marking, and color.
* *
@ -62,6 +65,7 @@ public class MarkedVertex<T extends VertexMarking> extends Vertex {
this.yCord = yCord; this.yCord = yCord;
} }
// GETTERS // GETTERS
/** /**
@ -73,6 +77,7 @@ public class MarkedVertex<T extends VertexMarking> extends Vertex {
return this.marking; return this.marking;
} }
/** /**
* Gets the screen vertex used for visualization. * Gets the screen vertex used for visualization.
* *
@ -82,6 +87,7 @@ public class MarkedVertex<T extends VertexMarking> extends Vertex {
return this.screenVertex; return this.screenVertex;
} }
/** /**
* Gets the coordinates of the vertex. * Gets the coordinates of the vertex.
* *
@ -91,6 +97,7 @@ public class MarkedVertex<T extends VertexMarking> extends Vertex {
return new int[]{this.xCord, this.yCord}; return new int[]{this.xCord, this.yCord};
} }
// SETTERS // SETTERS
/** /**
@ -102,6 +109,7 @@ public class MarkedVertex<T extends VertexMarking> extends Vertex {
this.marking = t; this.marking = t;
} }
/** /**
* Sets the coordinates of the vertex and updates the screen vertex's position. * Sets the coordinates of the vertex and updates the screen vertex's position.
* *
@ -114,6 +122,7 @@ public class MarkedVertex<T extends VertexMarking> extends Vertex {
this.screenVertex.setYpos(cords[1]); this.screenVertex.setYpos(cords[1]);
} }
// OUTPUT // OUTPUT
/** /**

View File

@ -13,6 +13,7 @@ public class NameDoesNotExistException extends Exception {
super(); super();
} }
/** /**
* Constructs a new NameDoesNotExistException with the specified detail message. * Constructs a new NameDoesNotExistException with the specified detail message.
* *
@ -22,6 +23,7 @@ public class NameDoesNotExistException extends Exception {
super(message); super(message);
} }
/** /**
* Constructs a new NameDoesNotExistException with the specified detail message and cause. * Constructs a new NameDoesNotExistException with the specified detail message and cause.
* *
@ -32,6 +34,7 @@ public class NameDoesNotExistException extends Exception {
super(message, cause); super(message, cause);
} }
/** /**
* Constructs a new NameDoesNotExistException with the specified cause and a detail message * Constructs a new NameDoesNotExistException with the specified cause and a detail message
* that includes the cause's description. * that includes the cause's description.
@ -45,8 +48,6 @@ public class NameDoesNotExistException extends Exception {
/** /**
* Represents an element stored in a priority queue for graph algorithms. * Represents an element stored in a priority queue for graph algorithms.
* *
@ -85,6 +86,7 @@ class WrapperElement<T extends VertexMarking> {
return this.element; return this.element;
} }
/** /**
* Retrieves the priority associated with this wrapper element. * Retrieves the priority associated with this wrapper element.
* *
@ -112,7 +114,6 @@ class WrapperElement<T extends VertexMarking> {
/** /**
* Comparator for comparing WrapperElement objects based on their priority. * Comparator for comparing WrapperElement objects based on their priority.
* *

View File

@ -349,7 +349,6 @@ public class UndirectedGraph<T extends VertexMarking, U extends EdgeMarking> ext
* @param n2 The ending vertex of the shortest path. * @param n2 The ending vertex of the shortest path.
* @return The length of the shortest path between n1 and n2. * @return The length of the shortest path between n1 and n2.
*/ */
public int getShortestPathAStar(MarkedVertex<T> n1, MarkedVertex<T> n2) { public int getShortestPathAStar(MarkedVertex<T> n1, MarkedVertex<T> n2) {
// Erstellt Hashmap um Distanz von Startnoten zu jedem Knoten auf dem Graph zu tracken // Erstellt Hashmap um Distanz von Startnoten zu jedem Knoten auf dem Graph zu tracken

View File

@ -11,7 +11,6 @@ public abstract class VertexMarking extends Marking {
/** /**
* Represents a weight marking associated with a vertex in a graph. * Represents a weight marking associated with a vertex in a graph.
* Extends {@link VertexMarking}. * Extends {@link VertexMarking}.