Package graph
Klasse Graph<T extends VertexMarking,U extends EdgeMarking>
java.lang.Object
graph.Graph<T,U>
- Typparameter:
T
- Type parameter for vertex markings, extends VertexMarking.U
- Type parameter for edge markings, extends EdgeMarking.
- Bekannte direkte Unterklassen:
DirectedGraph
,UndirectedGraph
Abstract class representing a generic graph.
-
Feldübersicht
Modifizierer und TypFeldBeschreibungprivate Vector
<MarkedEdge<U>> Vector containing all marked edges in the graph.private String
The name of the graph.private Vector
<MarkedVertex<T>> Vector containing all marked vertices in the graph. -
Konstruktorübersicht
-
Methodenübersicht
Modifizierer und TypMethodeBeschreibungvoid
addEdge
(MarkedEdge<U> e) Adds an edge to the graph.void
addVertex
(MarkedVertex<T> n) Adds a vertex to the graph.boolean
areAdjacent
(MarkedVertex<T> n1, MarkedVertex<T> n2) Checks if two vertices are adjacent (connected by an edge) in the graph.boolean
areAdjacent
(String s1, String s2) Checks if two vertices identified by their names are adjacent (connected by an edge) in the graph.void
Resets the screen graph colors of all vertices to black.int
degree()
Computes and returns the degree of the graph.Returns all edges in the graph.Returns all vertices in the graph.abstract LogElementList
<OurLogElement> Abstract method to get the log list associated with the graph.getName()
Returns the name of the graph.abstract Graph
Abstract method to get the visualization representation of the graph.abstract double
getShortestPathAStar
(MarkedVertex<T> n1, MarkedVertex<T> n2) Abstract method to find the shortest path between two vertices using A* algorithm.abstract int
getShortestPathDijkstra
(MarkedVertex<T> n1, MarkedVertex<T> n2) Abstract method to find the shortest path between two vertices using Dijkstra's algorithm.boolean
hasEdge
(MarkedEdge<U> e) Checks if an edge is present in the graph.boolean
hasEdge
(MarkedVertex<T> v1, MarkedVertex<T> v2) Checks if there is an edge between two vertices in the graph.boolean
Checks if an edge with a specific name is present in the graph.boolean
Checks if there is an edge between two vertices identified by their names.boolean
hasLoop
(MarkedVertex<T> n) Checks if a vertex has a loop (an edge connecting it to itself) in the graph.boolean
Checks if a vertex identified by its name has a loop (an edge connecting it to itself) in the graph.boolean
hasVertex
(MarkedVertex<T> n) Checks if a vertex is present in the graph.boolean
Checks if a vertex with a specific name is present in the graph.int
Returns the number of edges in the graph.int
Returns the number of vertices in the graph.void
removeEdge
(MarkedEdge<U> e) Removes an edge from the graph.void
removeEdge
(String s) Removes an edge from the graph based on its name.void
Removes a vertex from the graph.void
Removes a vertex from the graph based on its name.void
Sets the name of the graph.toString()
Returns a string representation of the graph.
-
Felddetails
-
name
The name of the graph. -
vertexes
Vector containing all marked vertices in the graph. -
edges
Vector containing all marked edges in the graph.
-
-
Konstruktordetails
-
Graph
public Graph()Default constructor initializes an empty graph. -
Graph
Constructor that initializes the graph with a given name.- Parameter:
s
- The name of the graph.
-
-
Methodendetails
-
getName
Returns the name of the graph.- Gibt zurück:
- The name of the graph.
-
getAllEdges
Returns all edges in the graph.- Gibt zurück:
- Vector containing all edges in the graph.
-
getAllVertexes
Returns all vertices in the graph.- Gibt zurück:
- Vector containing all vertices in the graph.
-
getScreenGraph
Abstract method to get the visualization representation of the graph.- Gibt zurück:
- Visualization representation of the graph.
-
getLogList
Abstract method to get the log list associated with the graph.- Gibt zurück:
- LogElementList containing log elements associated with the graph.
-
setName
Sets the name of the graph.- Parameter:
s
- The name to set for the graph.
-
toString
Returns a string representation of the graph. -
addEdge
Adds an edge to the graph.- Parameter:
e
- The edge to add.
-
addVertex
Adds a vertex to the graph.- Parameter:
n
- The vertex to add.
-
removeEdge
Removes an edge from the graph.- Parameter:
e
- The edge to remove.
-
removeEdge
Removes an edge from the graph based on its name.- Parameter:
s
- The name of the edge to remove.- Löst aus:
NameDoesNotExistException
- If the edge with the specified name does not exist.
-
removeVertex
Removes a vertex from the graph.- Parameter:
n
- The vertex to remove.
-
removeVertex
Removes a vertex from the graph based on its name.- Parameter:
s
- The name of the vertex to remove.- Löst aus:
NameDoesNotExistException
- If the vertex with the specified name does not exist.
-
numberOfEdges
public int numberOfEdges()Returns the number of edges in the graph.- Gibt zurück:
- The number of edges in the graph.
-
numberOfVertexes
public int numberOfVertexes()Returns the number of vertices in the graph.- Gibt zurück:
- The number of vertices in the graph.
-
degree
public int degree()Computes and returns the degree of the graph.- Gibt zurück:
- The degree of the graph.
-
hasVertex
Checks if a vertex is present in the graph.- Parameter:
n
- The vertex to check.- Gibt zurück:
- True if the vertex is present, false otherwise.
-
hasVertex
Checks if a vertex with a specific name is present in the graph.- Parameter:
s
- The name of the vertex to check.- Gibt zurück:
- True if the vertex with the given name is present, false otherwise.
-
hasEdge
Checks if an edge is present in the graph.- Parameter:
e
- The edge to check.- Gibt zurück:
- True if the edge is present, false otherwise.
-
hasEdge
Checks if an edge with a specific name is present in the graph.- Parameter:
s
- The name of the edge to check.- Gibt zurück:
- True if the edge with the given name is present, false otherwise.
-
hasEdge
Checks if there is an edge between two vertices in the graph.- Parameter:
v1
- First vertex.v2
- Second vertex.- Gibt zurück:
- True if there is an edge between the vertices, false otherwise.
-
hasEdge
Checks if there is an edge between two vertices identified by their names.- Parameter:
s1
- Name of the first vertex.s2
- Name of the second vertex.- Gibt zurück:
- True if there is an edge between the vertices, false otherwise.
- Löst aus:
NameDoesNotExistException
- If one of the vertex names does not exist in the graph.
-
areAdjacent
Checks if two vertices are adjacent (connected by an edge) in the graph.- Parameter:
n1
- First vertex.n2
- Second vertex.- Gibt zurück:
- True if the vertices are adjacent, false otherwise.
-
areAdjacent
Checks if two vertices identified by their names are adjacent (connected by an edge) in the graph.- Parameter:
s1
- Name of the first vertex.s2
- Name of the second vertex.- Gibt zurück:
- True if the vertices are adjacent, false otherwise.
- Löst aus:
NameDoesNotExistException
- If one of the vertex names does not exist in the graph.
-
hasLoop
Checks if a vertex has a loop (an edge connecting it to itself) in the graph.- Parameter:
n
- The vertex to check.- Gibt zurück:
- True if the vertex has a loop, false otherwise.
-
hasLoop
Checks if a vertex identified by its name has a loop (an edge connecting it to itself) in the graph.- Parameter:
s
- The name of the vertex to check.- Gibt zurück:
- True if the vertex has a loop, false otherwise.
- Löst aus:
NameDoesNotExistException
- If the vertex name does not exist in the graph.
-
clearScreenGraphColor
public void clearScreenGraphColor()Resets the screen graph colors of all vertices to black. -
getShortestPathDijkstra
Abstract method to find the shortest path between two vertices using Dijkstra's algorithm.- Parameter:
n1
- Starting vertex.n2
- Destination vertex.- Gibt zurück:
- Length of the shortest path between the vertices.
-
getShortestPathAStar
Abstract method to find the shortest path between two vertices using A* algorithm.- Parameter:
n1
- Starting vertex.n2
- Destination vertex.- Gibt zurück:
- Length of the shortest path between the vertices.
-