Class SimpleGraph.SimpleVertex<T extends IDable,M>

java.lang.Object
dev.roanh.gmark.util.SimpleGraph.SimpleVertex<T,M>
Type Parameters:
T - The data type of data stored at vertices.
M - The metadata data type.
All Implemented Interfaces:
IDable
Enclosing class:
SimpleGraph<T extends IDable,M>

public static final class SimpleGraph.SimpleVertex<T extends IDable,M> extends Object implements IDable
Represents a single vertex in the graph.
  • Field Details

    • data

      private T extends IDable data
      The data stored at this vertex that uniquely identifies it in the graph.
    • edges

      private Set<SimpleGraph.SimpleEdge<T extends IDable,M>> edges
      The edges this vertex is an end point for.
    • metadata

      private M metadata
      The metadata stored at this vertex.
  • Constructor Details

    • SimpleVertex

      private SimpleVertex(T data)
      Constructs a new vertex with the given data.
      Parameters:
      data - The data uniquely identifying this vertex.
  • Method Details

    • getMetadata

      public M getMetadata()
      Gets the metadata stored at this vertex.
      Returns:
      The metadata stored at this vertex.
    • setMetadata

      public void setMetadata(M meta)
      Sets the metadata stored at this vertex.
      Parameters:
      meta - The new metadata to store at this vertex.
    • getEdges

      public Set<SimpleGraph.SimpleEdge<T,M>> getEdges()
      Gets a set of all edges that this vertex participates in as an end point.
      Returns:
      All the edges that this vertex is and end point of.
    • getData

      public T getData()
      Gets the data stored at this vertex. This piece of data uniquely identifies this vertex in the graph.
      Returns:
      The data associated with this vertex.
    • getDegree

      public int getDegree()
      Gets the degree of this vertex in the graph. This is equal to the number of edges that this vertex is and end point of.
      Returns:
      The degree of this vertex in the graph.
    • hasEdge

      public boolean hasEdge(SimpleGraph.SimpleVertex<T,M> target)
      Checks if this vertex has an edge to the given target vertex.
      Parameters:
      target - The vertex to check for an edge to.
      Returns:
      True if this vertex has and edge to the given target vertex.
    • getEdge

      Gets the edge from this vertex to the given target vertex.
      Parameters:
      target - The target vertex.
      Returns:
      The edge from this vertex to the given target vertex or null if no such edge exists.
    • getNeighbours

      public List<SimpleGraph.SimpleVertex<T,M>> getNeighbours()
      Gets a list of all the neighbour vertices for this vertex, excluding itself.
      Returns:
      All neighbours of this vertex.
    • getID

      public int getID()
      Gets the unique ID for this object. This ID uniquely identifies all objects of this type.

      Note that while this ID is unique for a given graph node, the uniqueness of a node in the graph is still determined by the data objected used to create the node. Hence two nodes with different IDs but the same data are in fact equal. Though this situation could only arise when comparing the IDs of nodes from different graph.

      Specified by:
      getID in interface IDable
      Returns:
      The unique ID for this object.
      See Also:
    • equals

      public boolean equals(Object other)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object