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
,
AbstractSparseVertex
UserDataContainer.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_Graph
factory, 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, getIncidentElements
addGraph_internal, getGraph, hashCode, initialize, removeGraph_internal
addUserDatum, clone, containsUserDatumKey, getUserDatum, getUserDatumCopyAction, getUserDatumKeyIterator, importUserData, removeUserDatum, setUserDataFactory, setUserDatum
finalize, getClass, notify, notifyAll, wait, wait, wait
getEqualEdge, getEquivalentEdge
getGraph, getIncidentElements
addUserDatum, clone, containsUserDatumKey, getUserDatum, getUserDatumCopyAction, getUserDatumKeyIterator, importUserData, removeUserDatum, setUserDatum
protected 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.IllegalArgumentException
public java.lang.String toString()
toString
in class java.lang.Object
Object.toString()
public java.util.Set getIncidentVertices()
ArchetypeEdge
ArchetypeVertex
.
For example, returns the source and destination vertices of a
directed edge.getIncidentVertices
in interface ArchetypeEdge
ArchetypeEdge.getIncidentVertices()
public Vertex getOpposite(Vertex vertex)
Edge
v
. 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 Edge
Edge.getOpposite(Vertex)
public int numVertices()
ArchetypeEdge
numVertices
in interface ArchetypeEdge
numVertices
in class AbstractArchetypeEdge
ArchetypeEdge.numVertices()
public boolean isIncident(ArchetypeVertex v)
ArchetypeEdge
true
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 ArchetypeEdge
isIncident
in class AbstractArchetypeEdge
ArchetypeEdge.isIncident(ArchetypeVertex)
public ArchetypeEdge copy(ArchetypeGraph newGraph)
newGraph
,
and copies this edge's user data to the new edge.copy
in interface ArchetypeEdge
copy
in class AbstractArchetypeEdge
newGraph
- the graph in which the copied edge will be placedArchetypeEdge.copy(edu.uci.ics.jung.graph.ArchetypeGraph)
public Pair getEndpoints()
Edge
getEndpoints
in interface Edge
Edge.getEndpoints()