Klasse Graph


public class Graph extends VisualizationElement
Represents a graph to visualize search algorithms.
  • Felddetails

    • vertexes

      private Vector<Vertex> vertexes
    • edges

      private Vector<Edge> edges
    • isDirected

      private boolean isDirected
    • edgeStyle

      private EdgeStyle edgeStyle
  • Konstruktordetails

    • Graph

      public Graph(Vector<Vertex> vertexes, Vector<Edge> edges, boolean isDirected, EdgeStyle edgeStyle)
      Creates a new Graph.
      Parameter:
      vertexes - Vertexes containing to the graph.
      edges - Edge containing to the graph.
      isDirected - Value whether the graph is directed or undirected.
      edgeStyle - Value in which style the edges will be drawn.
  • Methodendetails

    • draw

      public void draw(Graphics g)
      Beschreibung aus Klasse kopiert: VisualizationElement
      Draws the visualization element.
      Angegeben von:
      draw in Klasse VisualizationElement
      Parameter:
      g - The Graphics object to draw the element to the DrawArea.
    • setDirected

      public void setDirected(boolean isDirected)
      Parameter:
      isDirected - the isDirected to set
    • isDirected

      public boolean isDirected()
      Gibt zurück:
      the isDirected
    • setEdgeStyle

      public void setEdgeStyle(EdgeStyle edgeStyle)
      Parameter:
      edgeStyle - the edgeStyle to set
    • getEdgeStyle

      public EdgeStyle getEdgeStyle()
      Gibt zurück:
      the edge style
    • setVertexes

      public void setVertexes(Vector<Vertex> vertexes)
      Parameter:
      vertexes - The vertexes of the graph.
    • getVertexes

      public Vector<Vertex> getVertexes()
      Gibt zurück:
      the graph's vertexes.
    • setEdges

      public void setEdges(Vector<Edge> edges)
      Parameter:
      edges - The edges of the graph.
    • getEdges

      public Vector<Edge> getEdges()
      Gibt zurück:
      the graph's edges.
    • drawDirectedAngeledEdge

      private void drawDirectedAngeledEdge(Graphics g, Edge edge)
      Draws an directed angled edge.
      Parameter:
      g - Graphics object to draw to drawArea.
      edge - The edge to draw.
    • drawDirectedDirectEdge

      private void drawDirectedDirectEdge(Graphics g, Edge edge)
      Draws an directed direct edge.
      Parameter:
      g - Graphics object to draw to drawArea.
      edge - The edge to draw.
    • drawUndirectedDirectEdge

      private void drawUndirectedDirectEdge(Graphics g, Edge edge)
      Draws an undirected direct Edge.
      Parameter:
      g - Graphics object to draw to drawArea.
      edge - The edge to draw.
    • drawUndirectedAngeledEdge

      private void drawUndirectedAngeledEdge(Graphics g, Edge edge)
      Draws an undirected angled Edge.
      Parameter:
      g - Graphics object to draw to drawArea.
      edge - The edge to draw.
    • hasEdge

      private boolean hasEdge(Vertex source, Vertex destination)
      Decides whether the graph has an edge between two vertexes.
      Parameter:
      source - The source vertex.
      destination - The destination vertex.
      Gibt zurück:
      True if there is an edge between the two vertexes, false otherwise.