N
- E
- public class Edge<N,E> extends Object implements Comparable<Edge<N,E>>
This class gives a standard representation for an edge of a graph.
An edge is composed of a content, and two nodes
source
target
of class Node
.
This class implements class Comparable
and provides the compareTo(org.thegalactic.dgraph.Edge<N, E>)
method that compares the edge with those in parameter by sorting indexes of the nodes that compose it.
Therefore, edges can be stored in a sorted collection since they are comparable, and in particular in a sorted set where set operations are provided.
Constructor and Description |
---|
Edge(Node<N> source,
Node<N> target)
Constructs a new edge with the specified node as origin and destination node, and a null value as content.
|
Edge(Node<N> source,
Node<N> target,
E content)
Constructs a new edge with the specified node as origin and destination node, with the specified content.
|
Modifier and Type | Method and Description |
---|---|
int |
compareTo(Edge<N,E> edge)
Compares this edge with those in parameter, based on their identifiers.
|
boolean |
equals(Object object)
Compares this edge with the specified one.
|
E |
getContent()
Returns the content this edge.
|
Node<N> |
getSource()
Returns the source node of this edge.
|
Node<N> |
getTarget()
Returns the target node of this edge.
|
boolean |
hasContent()
Returns true if content of this edge is not the null value.
|
int |
hashCode()
Compute the hash code.
|
Edge<N,E> |
setContent(E content)
Replaces the content of this edge with the specified one.
|
String |
toString()
Returns a String representation of this edge.
|
public Edge(Node<N> source, Node<N> target, E content)
Constructs a new edge with the specified node as origin and destination node, with the specified content.
source
- the origin nodetarget
- the destination nodecontent
- the edge contentpublic final Node<N> getSource()
Returns the source node of this edge.
public final Node<N> getTarget()
Returns the target node of this edge.
public final Edge<N,E> setContent(E content)
Replaces the content of this edge with the specified one.
content
- The edge contentpublic final E getContent()
Returns the content this edge.
public final boolean hasContent()
Returns true if content of this edge is not the null value.
public boolean equals(Object object)
Compares this edge with the specified one.
public int hashCode()
Compute the hash code.
public final int compareTo(Edge<N,E> edge)
Compares this edge with those in parameter, based on their identifiers.
The result is zero if the identifiers are equal; positive if this edge’s identifier is greater, and negative otherwise.
This comparison method is needed target define a natural ordering. It allows target use objects of this class in a sorted collection
compareTo
in interface Comparable<Edge<N,E>>
edge
- the specified element target be compared with this edgeCopyright © 2010–2016 The Galactic Organization. All rights reserved.