public interface ArchetypeVertex extends Element
Vertices are added to graphs in a two-stage process. First
the user calls the vertex constructor, yielding an instance,
v
, of ArchetypeVertex
. Then the user
calls g.addVertex(v)
, where g
is an
implementation of ArchetypeGraph
.
The two-stage nature of this process makes it possible to create "orphaned"
vertices that are not part of a graph.
This was done as a compromise between common practices in Java APIs
regarding the side effects of constructors, and the semantics of graphs.
However, the behavior of all ArchetypeVertex
methods, with
the exception of getGraph()
, is unspecified on orphaned vertices.
The JUNG Project implementations will never create orphaned
vertices, and we strongly recommend that users follow this practice
by nesting the constructor call inside the call to addVertex()
,
as in the following example:
g.addVertex(new VertexType());
where VertexType
is the type of vertex that the user wishes
to create.
ArchetypeEdge
,
ArchetypeGraph
UserDataContainer.CopyAction
Modifier and Type | Method and Description |
---|---|
ArchetypeVertex |
copy(ArchetypeGraph g)
Creates a copy of this vertex in graph
g . |
int |
degree()
Returns the number of edges incident to this vertex.
|
ArchetypeEdge |
findEdge(ArchetypeVertex v)
Returns an edge that connects this vertex to
v . |
java.util.Set |
findEdgeSet(ArchetypeVertex v)
Returns the set of all edges that connect this vertex
with the specified vertex
v . |
ArchetypeVertex |
getEqualVertex(ArchetypeGraph g)
Returns the vertex in graph
g , if any, that is
equal to this vertex. |
ArchetypeVertex |
getEquivalentVertex(ArchetypeGraph g)
Deprecated.
As of version 1.4, renamed to getEqualVertex(g).
|
java.util.Set |
getIncidentEdges()
Returns the set of edges which are incident to this vertex.
|
java.util.Set |
getNeighbors()
Returns the set of vertices which are connected to this vertex
via edges; each of these vertices should implement
ArchetypeVertex . |
boolean |
isIncident(ArchetypeEdge e)
Returns
true if the specified edge e is
incident to this vertex, and false otherwise. |
boolean |
isNeighborOf(ArchetypeVertex v)
Returns
true if the specified vertex v and
this vertex are each incident
to one or more of the same edges, and false otherwise. |
int |
numNeighbors()
Returns the number of neighbors that this vertex has.
|
getGraph, getIncidentElements
addUserDatum, clone, containsUserDatumKey, getUserDatum, getUserDatumCopyAction, getUserDatumKeyIterator, importUserData, removeUserDatum, setUserDatum
java.util.Set getNeighbors()
ArchetypeVertex
.
If this vertex is connected to itself with a self-loop, then
this vertex will be included in its own neighbor set.java.util.Set getIncidentEdges()
ArchetypeEdge
.int degree()
numNeighbors()
int numNeighbors()
degree()
ArchetypeVertex getEqualVertex(ArchetypeGraph g)
g
, if any, that is
equal to this vertex. Otherwise, returns null.
Two vertices are equal if one of them is an ancestor (via
copy()
) of the other.ArchetypeVertex getEquivalentVertex(ArchetypeGraph g)
boolean isNeighborOf(ArchetypeVertex v)
true
if the specified vertex v
and
this vertex are each incident
to one or more of the same edges, and false
otherwise.
The behavior of this method is undefined if v
is not
an element of this vertex's graph.boolean isIncident(ArchetypeEdge e)
true
if the specified edge e
is
incident to this vertex, and false
otherwise.
The behavior of this method is undefined if e
is not
an element of this vertex's graph.ArchetypeVertex copy(ArchetypeGraph g)
g
. The vertex
created will be equivalent to this vertex: given
v = this.copy(g)
, then
this.getEquivalentVertex(g) == v
, and
this.equals(v) == true
.g
- the graph in which the copied vertex will be placedArchetypeEdge findEdge(ArchetypeVertex v)
v
.
If this edge is not uniquely
defined (that is, if the graph contains more than one edge connecting
this vertex to v
), any of these edges
v
may be returned. findEdgeSet(v)
may be
used to return all such edges.
If v
is not connected to this vertex, returns
null
.findEdgeSet(ArchetypeVertex)
java.util.Set findEdgeSet(ArchetypeVertex v)
v
.
findEdge(v)
may be used to return
a single (arbitrary) element of this set.
If v
is not connected to this vertex, returns an empty Set
.findEdge(ArchetypeVertex)