edu.uci.ics.jung.graph.impl
Class AbstractSparseVertex

java.lang.Object
  extended byedu.uci.ics.jung.utils.UserData
      extended byedu.uci.ics.jung.graph.impl.AbstractSparseVertex
All Implemented Interfaces:
ArchetypeVertex, java.lang.Cloneable, UserDataContainer, Vertex
Direct Known Subclasses:
SimpleDirectedSparseVertex, SimpleSparseVertex, SimpleUndirectedSparseVertex

public abstract class AbstractSparseVertex
extends UserData
implements Vertex, java.lang.Cloneable

This class provides a skeletal implementation of the Vertex 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.

Author:
Scott White, Danyel Fisher, Joshua O'Madadhain
See Also:
AbstractSparseGraph, AbstractSparseEdge

Nested Class Summary
 
Nested classes inherited from class edu.uci.ics.jung.utils.UserDataContainer
UserDataContainer.CopyAction
 
Field Summary
 
Fields inherited from class edu.uci.ics.jung.utils.UserData
CLONE, REMOVE, SHARED
 
Method Summary
 ArchetypeVertex copy(ArchetypeGraph newGraph)
          Creates a copy of this vertex in graph g.
 int degree()
          Returns the number of edges incident to this vertex.
 boolean equals(java.lang.Object o)
          Returns true if o is an instance of ArchetypeVertex that is equivalent to this vertex.
 Edge findEdge(Vertex v)
          Returns the edge that connects this vertex to the specified vertex v.
 java.util.Set findEdgeSet(Vertex v)
          Returns the set of all edges that connect this vertex with the specified vertex v.
 ArchetypeVertex getEqualVertex(ArchetypeGraph ag)
          Returns the vertex in the specified graph ag that is equivalent to this vertex.
 ArchetypeVertex getEquivalentVertex(ArchetypeGraph ag)
          Deprecated. As of version 1.4, renamed to getEqualVertex(ag).
 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.
 int hashCode()
           
 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.
 java.lang.String toString()
          Returns a human-readable representation of this vertex.
 
Methods inherited from class edu.uci.ics.jung.utils.UserData
addUserDatum, containsUserDatumKey, getUserDatum, getUserDatumCopyAction, getUserDatumKeyIterator, importUserData, removeUserDatum, setUserDatum
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.uci.ics.jung.graph.Vertex
getInEdges, getOutEdges, getPredecessors, getSuccessors, inDegree, isDest, isPredecessorOf, isSource, isSuccessorOf, numPredecessors, numSuccessors, outDegree
 
Methods inherited from interface edu.uci.ics.jung.utils.UserDataContainer
addUserDatum, containsUserDatumKey, getUserDatum, getUserDatumCopyAction, getUserDatumKeyIterator, importUserData, removeUserDatum, setUserDatum
 

Method Detail

getGraph

public ArchetypeGraph getGraph()
Description copied from interface: ArchetypeVertex
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.

Specified by:
getGraph in interface ArchetypeVertex
See Also:
ArchetypeVertex.getGraph()

getNeighbors

public java.util.Set getNeighbors()
Description copied from interface: ArchetypeVertex
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.

Specified by:
getNeighbors in interface ArchetypeVertex
See Also:
ArchetypeVertex.getNeighbors()

numNeighbors

public int numNeighbors()
Description copied from interface: ArchetypeVertex
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.

Specified by:
numNeighbors in interface ArchetypeVertex
See Also:
ArchetypeVertex.numNeighbors()

getIncidentEdges

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

Specified by:
getIncidentEdges in interface ArchetypeVertex
See Also:
ArchetypeVertex.getIncidentEdges()

degree

public int degree()
Description copied from interface: ArchetypeVertex
Returns the number of edges incident to this vertex. Special cases of interest:

Specified by:
degree in interface ArchetypeVertex
Returns:
int the degree of this node
See Also:
ArchetypeVertex.degree()

equals

public boolean equals(java.lang.Object o)
Returns true if o is an instance of ArchetypeVertex that is equivalent to this vertex. Respects the vertex equivalences which are established by copy() and referenced by getEquivalentVertex().

See Also:
Object.equals(java.lang.Object), ArchetypeVertex.getEqualVertex(ArchetypeGraph), ArchetypeVertex.copy(edu.uci.ics.jung.graph.ArchetypeGraph)

getEqualVertex

public ArchetypeVertex getEqualVertex(ArchetypeGraph ag)
Returns the vertex in the specified graph ag that is equivalent to this vertex. If there is no such vertex, or if ag is not an instance of AbstractSparseGraph, returns null.

Specified by:
getEqualVertex in interface ArchetypeVertex
See Also:
ArchetypeVertex.getEqualVertex(ArchetypeGraph)

getEquivalentVertex

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

Specified by:
getEquivalentVertex in interface ArchetypeVertex

hashCode

public int hashCode()
See Also:
Object.hashCode()

isNeighborOf

public boolean isNeighborOf(ArchetypeVertex v)
Description copied from interface: ArchetypeVertex
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.

Specified by:
isNeighborOf in interface ArchetypeVertex
See Also:
ArchetypeVertex.isNeighborOf(ArchetypeVertex)

isIncident

public boolean isIncident(ArchetypeEdge e)
Description copied from interface: ArchetypeVertex
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.

Specified by:
isIncident in interface ArchetypeVertex
See Also:
ArchetypeVertex.isIncident(ArchetypeEdge)

findEdge

public Edge findEdge(Vertex v)
Returns the edge that connects this vertex to the specified vertex v. This is a simple implementation which checks the opposite vertex of each outgoing edge of this vertex; this solution is general, but not efficient.

Specified by:
findEdge in interface Vertex
See Also:
Vertex.findEdge(Vertex)

findEdgeSet

public java.util.Set findEdgeSet(Vertex v)
Description copied from interface: Vertex
Returns the set of all edges that connect this vertex with the specified vertex v. If v is not connected to this vertex, returns an empty Set.

Specified by:
findEdgeSet in interface Vertex
See Also:
Vertex.findEdgeSet(Vertex)

copy

public ArchetypeVertex copy(ArchetypeGraph newGraph)
Description copied from interface: ArchetypeVertex
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.

Specified by:
copy in interface ArchetypeVertex
Parameters:
newGraph - the graph in which the copied vertex will be placed
Returns:
the vertex created
See Also:
ArchetypeVertex.copy(ArchetypeGraph)

toString

public java.lang.String toString()
Returns a human-readable representation of this vertex.

Overrides:
toString in class UserData
See Also:
Object.toString()