Class Graph

java.lang.Object
com.thomas.graphs.Unweighted.Graph

public class Graph extends Object
An implenation of a graph that does not have weighted edges
  • Field Details

    • INFINITY

      public static final int INFINITY
      A quick reference for "Infinity"
      See Also:
    • vertices

      public List<Vertex> vertices
      The vertices in the graph
  • Constructor Details

    • Graph

      public Graph()
      Creates an empty graph
    • Graph

      public Graph(LinkedList<Vertex> vertices)
      Creates a new graph with vertices
      Parameters:
      vertices - The vertices in the graph
  • Method Details

    • addVertex

      public void addVertex(Vertex vertex)
      Adds a vertex to the graph
      Parameters:
      vertex - The vertex to be added to the graph
    • addEdge

      public void addEdge(Vertex source, Vertex destination)
      Adds a directional edge between two vertice
      Parameters:
      source - The vertex that the destination is being added to
      destination - THe destination vertex
    • addUndirectedEdge

      public void addUndirectedEdge(Vertex source, Vertex destination)
      Adds an undirected edge between two vertices
      Parameters:
      source - The first vertex
      destination - The other vertex
    • bfs

      public void bfs(Vertex source)
      An implemnetaion of the breadth-first search algorithm
      Parameters:
      source - The source vertex
    • dfs

      public void dfs(Vertex source)
      An implemnetation of the depth-first search algorithm
      Parameters:
      source - The source vertex
    • recursiveDFS

      public void recursiveDFS(Vertex vertex)
      The recusersice defintion of the DFS algorithm
      Parameters:
      vertex - The current vertex