edu.uci.ics.jung.graph
Interface ArchetypeVertex

All Superinterfaces:
UserDataContainer
All Known Subinterfaces:
GraphCollapser.CollapsedVertex, Hypervertex, Vertex
All Known Implementing Classes:
AbstractSparseVertex, BipartiteGraphCollapser.CollapsedBipartiteVertex, GraphCollapser.CollapsedSparseVertex, HypervertexBPG

public interface ArchetypeVertex
extends UserDataContainer

A interface for vertex implementations in generalized graphs.

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.

Author:
Danyel Fisher, Joshua O'Madadhain, Scott White
See Also:
ArchetypeEdge, ArchetypeGraph

Nested Class Summary
 
Nested classes inherited from class edu.uci.ics.jung.utils.UserDataContainer
UserDataContainer.CopyAction
 
Method Summary
 ArchetypeVertex copy(ArchetypeGraph g)
          Creates a copy of this vertex in graph g.
 int degree()
          Returns the number of edges incident to this vertex.
 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).
 ArchetypeGraph getGraph()
          Returns a reference to the graph that contains this vertex.
 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.
 
Methods inherited from interface edu.uci.ics.jung.utils.UserDataContainer
addUserDatum, containsUserDatumKey, getUserDatum, getUserDatumCopyAction, getUserDatumKeyIterator, importUserData, removeUserDatum, setUserDatum
 

Method Detail

getGraph

public ArchetypeGraph getGraph()
Returns a reference to the graph that contains this vertex. If this vertex is not contained by any graph (is an "orphaned" vertex), returns null.


getNeighbors

public java.util.Set getNeighbors()
Returns the set of vertices which are connected to this vertex via edges; each of these vertices should implement ArchetypeVertex. If this vertex is connected to itself with a self-loop, then this vertex will be included in its own neighbor set.


getIncidentEdges

public java.util.Set getIncidentEdges()
Returns the set of edges which are incident to this vertex. Each of these edges should implement ArchetypeEdge.


degree

public int degree()
Returns the number of edges incident to this vertex. Special cases of interest:

Returns:
int the degree of this node
See Also:
numNeighbors()

numNeighbors

public int numNeighbors()
Returns the number of neighbors that this vertex has. If the graph is directed, the value returned will be the sum of the number of predecessors and the number of successors that this vertex has.

Since:
1.1.1
See Also:
degree()

getEqualVertex

public ArchetypeVertex getEqualVertex(ArchetypeGraph g)
Returns the vertex in graph 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.

See Also:
copy(ArchetypeGraph), ArchetypeEdge.getEqualEdge(ArchetypeGraph)

getEquivalentVertex

public ArchetypeVertex getEquivalentVertex(ArchetypeGraph g)
Deprecated. As of version 1.4, renamed to getEqualVertex(g).


isNeighborOf

public 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. The behavior of this method is undefined if v is not an element of this vertex's graph.


isIncident

public boolean isIncident(ArchetypeEdge e)
Returns 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.


copy

public ArchetypeVertex copy(ArchetypeGraph g)
Creates a copy of this vertex in graph 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.

Parameters:
g - the graph in which the copied vertex will be placed
Returns:
the vertex created