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

public abstract class Graph<T extends VertexMarking,U extends EdgeMarking> extends Object
Abstract class representing a generic graph.
  • Felddetails

  • Konstruktordetails

    • Graph

      public Graph()
      Default constructor initializes an empty graph.
    • Graph

      public Graph(String s)
      Constructor that initializes the graph with a given name.
      Parameter:
      s - The name of the graph.
  • Methodendetails

    • getName

      public String getName()
      Returns the name of the graph.
      Gibt zurück:
      The name of the graph.
    • getAllEdges

      public Vector<MarkedEdge<U>> getAllEdges()
      Returns all edges in the graph.
      Gibt zurück:
      Vector containing all edges in the graph.
    • getAllVertexes

      public Vector<MarkedVertex<T>> getAllVertexes()
      Returns all vertices in the graph.
      Gibt zurück:
      Vector containing all vertices in the graph.
    • getScreenGraph

      public abstract Graph getScreenGraph()
      Abstract method to get the visualization representation of the graph.
      Gibt zurück:
      Visualization representation of the graph.
    • getLogList

      public abstract LogElementList<OurLogElement> getLogList()
      Abstract method to get the log list associated with the graph.
      Gibt zurück:
      LogElementList containing log elements associated with the graph.
    • setName

      public void setName(String s)
      Sets the name of the graph.
      Parameter:
      s - The name to set for the graph.
    • toString

      public String toString()
      Returns a string representation of the graph.
      Setzt außer Kraft:
      toString in Klasse Object
      Gibt zurück:
      String representation of the graph.
    • addEdge

      public void addEdge(MarkedEdge<U> e)
      Adds an edge to the graph.
      Parameter:
      e - The edge to add.
    • addVertex

      public void addVertex(MarkedVertex<T> n)
      Adds a vertex to the graph.
      Parameter:
      n - The vertex to add.
    • removeEdge

      public void removeEdge(MarkedEdge<U> e)
      Removes an edge from the graph.
      Parameter:
      e - The edge to remove.
    • removeEdge

      public void removeEdge(String s) throws NameDoesNotExistException
      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

      public void removeVertex(MarkedVertex<T> n)
      Removes a vertex from the graph.
      Parameter:
      n - The vertex to remove.
    • removeVertex

      public void removeVertex(String s) throws NameDoesNotExistException
      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

      public boolean hasVertex(MarkedVertex<T> n)
      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

      public boolean hasVertex(String s)
      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

      public boolean hasEdge(MarkedEdge<U> e)
      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

      public boolean hasEdge(String s)
      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

      public boolean hasEdge(MarkedVertex<T> v1, MarkedVertex<T> v2)
      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

      public boolean hasEdge(String s1, String s2) throws NameDoesNotExistException
      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

      public boolean areAdjacent(MarkedVertex<T> n1, MarkedVertex<T> n2)
      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

      public boolean areAdjacent(String s1, String s2) throws NameDoesNotExistException
      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

      public boolean hasLoop(MarkedVertex<T> n)
      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

      public boolean hasLoop(String s) throws NameDoesNotExistException
      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

      public abstract int getShortestPathDijkstra(MarkedVertex<T> n1, MarkedVertex<T> n2)
      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

      public abstract double getShortestPathAStar(MarkedVertex<T> n1, MarkedVertex<T> n2)
      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.