Package dev.roanh.gmark.util
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>
Represents a single directed edge in the graph that
can have associated data.
-
Field Summary
Modifier and TypeFieldDescriptionprivate E
The data associated with this edge, can benull
.private UniqueGraph.GraphNode<V,
E> The source node for this edge.private UniqueGraph.GraphNode<V,
E> The target node for this edge. -
Constructor Summary
ModifierConstructorDescriptionprivate
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. -
Method Summary
Modifier and TypeMethodDescriptionboolean
getData()
Gets the data associated with this edge.Gets the data stored at the source node for this edge.Gets the source node for this edge.Gets the data stored at the target node for this edge.Gets the target node for this edge.int
hashCode()
void
remove()
Removes this node from the graph.boolean
restore()
If this edge was previously removed from the graph usingremove()
this method can be used to add the edge back to the graph.toString()
-
Field Details
-
source
The source node for this edge. -
target
The target node for this edge. -
data
The data associated with this edge, can benull
.
-
-
Constructor Details
-
GraphEdge
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 benull
.
-
-
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 usingremove()
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
Gets the source node for this edge.- Returns:
- The source node for this edge.
- See Also:
-
getTargetNode
Gets the target node for this edge.- Returns:
- The target node for this edge.
- See Also:
-
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
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
Gets the data associated with this edge.- Returns:
- The data associated with this edge,
possibly
null
.
-
toString
-
equals
-
hashCode
public int hashCode()
-