public abstract class AbstractSparseEdge extends AbstractArchetypeEdge implements Edge
Edge
interface to minimize the effort required to implement this interface.
It is appropriate for sparse graphs (those in which each vertex
is connected to only a few other vertices); for dense graphs (those in
which each vertex is connected to most other vertices), another
implementation might be more appropriate.
This class extends UserData, which provides storage and
retrieval mechanisms for user-defined data for each edge instance.
This allows users to attach data to edges without having to extend
this class.
AbstractSparseGraph,
AbstractSparseVertexUserDataContainer.CopyAction| Modifier and Type | Field and Description |
|---|---|
protected Vertex |
mFrom
One of the two incident vertices of this edge.
|
protected Vertex |
mTo
One of the two incident vertices of this edge.
|
id, m_Graphfactory, udc_delegate| Constructor and Description |
|---|
AbstractSparseEdge(Vertex from,
Vertex to)
Creates an edge connecting vertices
from and
to. |
| Modifier and Type | Method and Description |
|---|---|
ArchetypeEdge |
copy(ArchetypeGraph newGraph)
Creates a copy of this edge in the specified graph
newGraph,
and copies this edge's user data to the new edge. |
Pair |
getEndpoints()
Returns a pair consisting of both incident vertices.
|
java.util.Set |
getIncidentVertices()
Returns the set of vertices which are incident to this edge.
|
Vertex |
getOpposite(Vertex vertex)
Returns the vertex at the opposite end of this edge from the
specified vertex
v. |
boolean |
isIncident(ArchetypeVertex v)
Returns
true if the specified vertex v
is incident to this edge, and false otherwise. |
int |
numVertices()
Returns the number of vertices which are incident to this edge.
|
java.lang.String |
toString()
Returns a human-readable representation of this edge.
|
equals, getEqualEdge, getEquivalentEdge, getIncidentElementsaddGraph_internal, getGraph, hashCode, initialize, removeGraph_internaladdUserDatum, clone, containsUserDatumKey, getUserDatum, getUserDatumCopyAction, getUserDatumKeyIterator, importUserData, removeUserDatum, setUserDataFactory, setUserDatumfinalize, getClass, notify, notifyAll, wait, wait, waitgetEqualEdge, getEquivalentEdgegetGraph, getIncidentElementsaddUserDatum, clone, containsUserDatumKey, getUserDatum, getUserDatumCopyAction, getUserDatumKeyIterator, importUserData, removeUserDatum, setUserDatumprotected Vertex mFrom
protected Vertex mTo
public AbstractSparseEdge(Vertex from, Vertex to)
from and
to. The order of the arguments is significant for
implementations of
DirectedEdge which extend this class, and is not
significant for implementations of UndirectedEdge
which extend this class.
Disallows the following:
from to
vertex to)
IllegalArgumentException to
be thrown.from - one incident vertex (if edge is directed, the source)to - the other incident vertex (if edge is directed, the destination)java.lang.IllegalArgumentExceptionpublic java.lang.String toString()
toString in class java.lang.ObjectObject.toString()public java.util.Set getIncidentVertices()
ArchetypeEdgeArchetypeVertex.
For example, returns the source and destination vertices of a
directed edge.getIncidentVertices in interface ArchetypeEdgeArchetypeEdge.getIncidentVertices()public Vertex getOpposite(Vertex vertex)
Edgev. Throws
IllegalArgumentException if v is
not incident to this edge.
For example, if this edge connects vertices a and
b, this.getOpposite(a) returns
b.
getOpposite in interface EdgeEdge.getOpposite(Vertex)public int numVertices()
ArchetypeEdgenumVertices in interface ArchetypeEdgenumVertices in class AbstractArchetypeEdgeArchetypeEdge.numVertices()public boolean isIncident(ArchetypeVertex v)
ArchetypeEdgetrue if the specified vertex v
is incident to this edge, and false otherwise.
The behavior of this method is undefined if v is not
an element of this edge's graph.isIncident in interface ArchetypeEdgeisIncident in class AbstractArchetypeEdgeArchetypeEdge.isIncident(ArchetypeVertex)public ArchetypeEdge copy(ArchetypeGraph newGraph)
newGraph,
and copies this edge's user data to the new edge.copy in interface ArchetypeEdgecopy in class AbstractArchetypeEdgenewGraph - the graph in which the copied edge will be placedArchetypeEdge.copy(edu.uci.ics.jung.graph.ArchetypeGraph)public Pair getEndpoints()
EdgegetEndpoints in interface EdgeEdge.getEndpoints()