Class UniqueGraph.GraphEdge<V,E>

java.lang.Object
dev.roanh.gmark.util.UniqueGraph.GraphEdge<V,E>
Type Parameters:
V - The type of data stored at the graph nodes.
E - The type of data stored at the graph edges.
Enclosing class:
UniqueGraph<V,E>

public static class UniqueGraph.GraphEdge<V,E> extends Object
Represents a single directed edge in the graph that can have associated data.
  • Field Details

    • source

      private UniqueGraph.GraphNode<V,E> source
      The source node for this edge.
    • target

      private UniqueGraph.GraphNode<V,E> target
      The target node for this edge.
    • data

      private E data
      The data associated with this edge, can be null.
  • Constructor Details

    • GraphEdge

      private GraphEdge(UniqueGraph.GraphNode<V,E> source, UniqueGraph.GraphNode<V,E> target, E data)
      Constructs a new edge with the given source, target and associated data.
      Parameters:
      source - The source node for this edge.
      target - The target node for this edge.
      data - The data associated with this edge, allowed to be null.
  • Method Details

    • remove

      public void remove()
      Removes this node from the graph. After removal this node still references remaining graph nodes.
    • restore

      public boolean restore()
      If this edge was previously removed from the graph using remove() this method can be used to add the edge back to the graph. If an equivalent edge was added in the mean time then the edge is not restored.
      Returns:
      True if the edge was restored, false if an equivalent edge was already present.
    • getSourceNode

      public UniqueGraph.GraphNode<V,E> getSourceNode()
      Gets the source node for this edge.
      Returns:
      The source node for this edge.
      See Also:
    • getTargetNode

      public UniqueGraph.GraphNode<V,E> getTargetNode()
      Gets the target node for this edge.
      Returns:
      The target node for this edge.
      See Also:
    • getSource

      public V getSource()
      Gets the data stored at the source node for this edge.
      Returns:
      The data stored at the source node for this edge.
      See Also:
    • getTarget

      public V getTarget()
      Gets the data stored at the target node for this edge.
      Returns:
      The data stored at the target node for this edge.
      See Also:
    • getData

      public E getData()
      Gets the data associated with this edge.
      Returns:
      The data associated with this edge, possibly null.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

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

      public int hashCode()
      Overrides:
      hashCode in class Object