public class SimpleUndirectedSparseVertex extends AbstractSparseVertex
Vertex
that resides in a
undirected graph; none of its adjoining edges may be parallel.
This implementation stores hash tables that map the neighbors
of this vertex to its incident edges. This enables an
efficient implementation of findEdge(Vertex)
.
UndirectedGraph
,
UndirectedEdge
UserDataContainer.CopyAction
id, m_Graph
factory, udc_delegate
Constructor and Description |
---|
SimpleUndirectedSparseVertex() |
Modifier and Type | Method and Description |
---|---|
protected void |
addNeighbor_internal(Edge e,
Vertex v)
Adds the specified edge
e and vertex v
to the internal data structures of this vertex. |
Edge |
findEdge(Vertex v)
Returns the edge that connects this
vertex to the specified vertex
v , or
null if there is no such edge. |
java.util.Set |
findEdgeSet(Vertex v)
Returns the set of edges that connect this vertex to the
specified vertex.
|
protected java.util.Collection |
getEdges_internal()
Returns a set containing all the incident edges of this vertex.
|
java.util.Set |
getInEdges()
Returns the set of incoming edges of this vertex.
|
protected java.util.Collection |
getNeighbors_internal()
Returns a set containing all neighbors of this vertex.
|
protected java.util.Map |
getNeighborsToEdges()
Returns a map from the successors of this vertex to its outgoing
edges.
|
java.util.Set |
getOutEdges()
Returns the set of outgoing edges of this vertex.
|
java.util.Set |
getPredecessors()
Returns the set of predecessors of this vertex.
|
java.util.Set |
getSuccessors()
Returns the set of successors of this vertex.
|
int |
inDegree()
Returns the number of incoming edges that are incident to this
vertex.
|
protected void |
initialize()
Initializes all the data structures for this element.
|
boolean |
isDest(Edge e)
Returns
true if this vertex is a destination of
the specified edge e , and false otherwise. |
boolean |
isPredecessorOf(Vertex v)
Returns
true if this vertex is a predecessor of
the specified vertex v , and false otherwise. |
boolean |
isSource(Edge e)
Returns
true if this vertex is a source of
the specified edge e , and false otherwise. |
boolean |
isSuccessorOf(Vertex v)
Returns
true if this vertex is a successor of
the specified vertex v , and false otherwise. |
int |
numPredecessors()
Returns the number of predecessors of this vertex.
|
int |
numSuccessors()
Returns the number of successors of this vertex.
|
int |
outDegree()
Returns the number of outgoing edges that are incident to this
vertex.
|
protected void |
removeNeighbor_internal(Edge connectingEdge,
Vertex neighbor)
Removes the neighbor from this vertex's internal map.
|
protected void |
setNeighborsToEdges(java.util.Map neighborsToEdges)
Sets this vertex's internal successor -> out-edge map to
the specified map
succsToOutEdges . |
copy, findEdge, findEdgeSet, toString
degree, equals, getEqualVertex, getEquivalentVertex, getIncidentEdges, getIncidentElements, getNeighbors, isIncident, isNeighborOf, numNeighbors
addGraph_internal, getGraph, hashCode, removeGraph_internal
addUserDatum, clone, containsUserDatumKey, getUserDatum, getUserDatumCopyAction, getUserDatumKeyIterator, importUserData, removeUserDatum, setUserDataFactory, setUserDatum
finalize, getClass, notify, notifyAll, wait, wait, wait
degree, getEqualVertex, getEquivalentVertex, getIncidentEdges, getNeighbors, isIncident, isNeighborOf, numNeighbors
getGraph, getIncidentElements
addUserDatum, clone, containsUserDatumKey, getUserDatum, getUserDatumCopyAction, getUserDatumKeyIterator, importUserData, removeUserDatum, setUserDatum
public java.util.Set getPredecessors()
Vertex
v
is a predecessor of this vertex if and only if
v.isPredecessorOf(this)
returns true
.
Each element of the set returned should implement Vertex
.Vertex.getPredecessors()
public int numPredecessors()
Vertex
Vertex.numPredecessors()
public java.util.Set getSuccessors()
Vertex
v
is a successor of this vertex if and only if
v.isSuccessorOf(this)
returns true
.
Each element of the set returned should implement Vertex
.Vertex.getSuccessors()
public int numSuccessors()
Vertex
Vertex.numPredecessors()
public java.util.Set getInEdges()
Vertex
e
is an incoming edge of this vertex if and only if
this.isDest(e)
returns true
.
Each element of the set returned should implement Edge
.Vertex.getInEdges()
public java.util.Set getOutEdges()
Vertex
e
is an outgoing edge of this vertex if and only if
this.isSource(e)
returns true
.
Each element of the set returned should implement Edge
.Vertex.getOutEdges()
public int inDegree()
Vertex
Vertex.inDegree()
public int outDegree()
Vertex
Vertex.outDegree()
public boolean isSuccessorOf(Vertex v)
Vertex
true
if this vertex is a successor of
the specified vertex v
, and false
otherwise.
This vertex is a successor of v
if and only if
there exists an edge e
such that
v.isSource(e) == true
and
this.isDest(e) == true
.
The behavior of this method is undefined if v
is not
an element of this vertex's graph.Vertex.isSuccessorOf(Vertex)
public boolean isPredecessorOf(Vertex v)
Vertex
true
if this vertex is a predecessor of
the specified vertex v
, and false
otherwise.
This vertex is a predecessor of v
if and only if
there exists an edge e
such that
this.isSource(e) == true
and
v.isDest(e) == true
.
The behavior of this method is undefined if v
is not
an element of this vertex's graph.Vertex.isPredecessorOf(Vertex)
public boolean isSource(Edge e)
Vertex
true
if this vertex is a source of
the specified edge e
, and false
otherwise.
A vertex v
is a source of e
if e
is an outgoing edge of v
.
The behavior of this method is undefined if e
is not
an element of this vertex's graph.Vertex.isSource(Edge)
public boolean isDest(Edge e)
Vertex
true
if this vertex is a destination of
the specified edge e
, and false
otherwise.
A vertex v
is a destination of e
if e
is an incoming edge of v
.
The behavior of this method is undefined if e
is not
an element of this vertex's graph.Vertex.isDest(Edge)
public Edge findEdge(Vertex v)
v
, or
null
if there is no such edge.
Implemented using a hash table for a performance
improvement over the implementation in
AbstractSparseVertex
.findEdge
in interface Vertex
findEdge
in class AbstractSparseVertex
Vertex.findEdge(Vertex)
public java.util.Set findEdgeSet(Vertex v)
findEdge(v)
.findEdgeSet
in interface Vertex
findEdgeSet
in class AbstractSparseVertex
Vertex.findEdgeSet(Vertex)
protected void initialize()
AbstractElement
clone()
copies some information that should
not be in the new element.)initialize
in class AbstractElement
AbstractElement.initialize()
protected java.util.Collection getNeighbors_internal()
AbstractArchetypeVertex
getNeighbors_internal
in class AbstractArchetypeVertex
AbstractArchetypeVertex.getNeighbors_internal()
protected java.util.Collection getEdges_internal()
AbstractArchetypeVertex
getEdges_internal
in class AbstractArchetypeVertex
AbstractArchetypeVertex.getEdges_internal()
protected void addNeighbor_internal(Edge e, Vertex v)
AbstractSparseVertex
e
and vertex v
to the internal data structures of this vertex.addNeighbor_internal
in class AbstractSparseVertex
e
- the new incident edge of this vertexv
- the new neighbor of this vertexAbstractSparseVertex.addNeighbor_internal(Edge, Vertex)
protected void removeNeighbor_internal(Edge connectingEdge, Vertex neighbor)
removeNeighbor_internal
in class AbstractSparseVertex
connectingEdge
- the incident edge of this vertex which is being removedneighbor
- the neighbor of this vertex which is being removedAbstractSparseVertex.removeNeighbor_internal(Edge, Vertex)
protected java.util.Map getNeighborsToEdges()
protected void setNeighborsToEdges(java.util.Map neighborsToEdges)
succsToOutEdges
.
This method should not be directly accessed by users.