java.lang.Object
io.github.tigerbotics7125.tigerlib.math.graph.Graph<T>

public class Graph<T> extends Object
This class represents a collection of vertecies and edges defining traditional weighted graph.
Since:
2023
  • Constructor Details

    • Graph

      public Graph()
      Creates a new Graph.
  • Method Details

    • getVerticies

      public Stream<Vertex<T>> getVerticies()
      Returns:
      A Stream object of all the verticies in this Graph Object.
    • getSuccessors

      public List<Tuple<Vertex<T>,Double>> getSuccessors(Vertex<T> vertex)
      Parameters:
      vertex - Vertex to get successors from.
      Returns:
      The successors or neighbors of the given Vertex.
    • contains

      public boolean contains(T vertexVal)
      Parameters:
      vertexVal - Value to be searched for.
      Returns:
      Whether this Graph contains a Vertex with the given value.
    • contains

      public boolean contains(Vertex<T> vertex)
      Parameters:
      vertex - Vertex to be searched for.
      Returns:
      Whether this Graph contains the provided Vertex.
    • addVertex

      public void addVertex(T vertexVal)
      Adds the value as a Vertex to this Graph.
      Parameters:
      vertexVal - Value to add.
    • addVertex

      public void addVertex(Vertex<T> vertex)
      Adds the Vertex to this Graph.
      Parameters:
      vertex - Vertex to add.
    • addEdge

      public void addEdge(T leftVal, T rightVal, double weight)
      Add an edge to this Graph between two verticies defined by the provided values.
      Parameters:
      leftVal - Value of the left Vertex.
      rightVal - Value of the right Vertex.
      weight - Travel cost between left and right, equal both ways.
    • addEdge

      public void addEdge(T leftVal, T rightVal, double weightLR, double weightRL)
      Add an edge to this Graph between two verticies defined by the provided values.
      Parameters:
      leftVal - Value of the left Vertex.
      rightVal - Value of the right Vertex.
      weightLR - Travel cost from left to right.
      weightRL - Travel cost from right to left.
    • addEdge

      public void addEdge(Vertex<T> left, Vertex<T> right, double weight)
      Add an edge to this Graph between two verticies.
      Parameters:
      left - Left Vertex.
      right - Right Vertex.
      weight - Travel cost between left and right, equal both ways.
    • addEdge

      public void addEdge(Vertex<T> left, Vertex<T> right, double weightLR, double weightRL)
      Add an edge to the Graph between two verticies.
      Parameters:
      left - Left Vertex.
      right - Right Vertex.
      weightLR - Travel cost from left to right.
      weightRL - Travel cost from right to left.