Class Vertex

java.lang.Object
com.javaholics.Vertex

public class Vertex extends Object
Represents a vertex in a graph. Each vertex maintains a list of its adjacent vertices. The graph is undirected, meaning that an edge between two vertices goes both ways.
Author:
Lindsay Kislingbury, Lea Wiranatha
  • Constructor Details

    • Vertex

      public Vertex(String label)
      Constructs a new vertex with the given label.
      Parameters:
      label - The label of the vertex.
  • Method Details

    • getLabel

      public String getLabel()
      Returns the label of this vertex.
      Returns:
      The label of this vertex.
    • getAdjacentVertices

      public List<Vertex> getAdjacentVertices()
      Returns a list of the vertices adjacent to this vertex.
      Returns:
      A list of the vertices adjacent to this vertex.
    • addAdjacentVertex

      public void addAdjacentVertex(Vertex vertex)
      Adds a vertex to the list of adjacent vertices.
      Parameters:
      vertex - The vertex to add as an adjacent vertex.