|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.scheinerman.graph.Vertex<E>
public class Vertex<E>
A vertex represents a node in a graph object. It has an associated integer value, and edges to other vertices.
Constructor Summary | |
---|---|
Vertex()
Creates a new Vertex object with no value. |
|
Vertex(E data)
|
|
Vertex(E data,
Location location)
|
|
Vertex(Location location)
Creates a new Vertex object at a given Location . |
Method Summary | |
---|---|
void |
addEdge(Edge<E> e)
Adds the given edge to this vertex object. Warning: this will not add the same edge to the other vertex. |
void |
addEdgeTo(Vertex<E> v)
Creates a new Edge object which connects this vertex to a given vertex. |
boolean |
equals(Vertex<E> obj)
Tests if the location of the two vertices are the same. |
java.util.Set<Vertex<E>> |
getConnectedVertices()
Returns a set of all vertices that are connected to this vertex via edges. |
E |
getData()
|
java.util.ArrayList<Edge<E>> |
getEdges()
Returns an array of all edges that this vertex connects to. |
Edge<E> |
getEdgeTo(Vertex<E> v)
Returns the edge object with which this vertex connects to a given vertex. |
Location |
getLocation()
This vertex's current location |
java.util.ArrayList<Vertex<E>> |
getNeighbors()
Returns all the neighbors of this vertex. |
Vertex<E> |
getOtherEnd(Edge<E> e)
Given an edge, returns the vertex that is not equal to this vertex. |
int |
getValue()
Returns the value associated with this object. |
boolean |
hasEdgeTo(Vertex<E> v)
Tests whether this vertex has a connection to a given vertex. |
boolean |
isSelected()
Returns whether this vertex has been graphical selected. |
boolean |
isVisited()
Returns whether this vertex has been visited during a traversal. |
void |
removeAllEdges()
Removes all edges from this vertex object, but not from the vertices they connect to. |
void |
removeEdgeTo(Vertex<E> v)
If there is an edge to the given vertex, it is removed from this vertex. Warning: This method should called from both vertex objects. |
void |
setData(E data)
|
void |
setLocation(Location location)
Sets a new location for this vertex object. |
void |
setSelected(boolean isSelected)
Changes the status of this objects selection for graphical interfaces. |
void |
setValue(int value)
Sets a new integer value for this vertex. |
void |
setVisited(boolean isVisited)
Sets this vertex as visited or unvisited for use in a traversal. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Vertex()
Vertex
object with no value.
public Vertex(E data)
public Vertex(Location location)
Vertex
object at a given Location
.
location
- - the location at which to create the vertex.public Vertex(E data, Location location)
Method Detail |
---|
public void addEdge(Edge<E> e)
addEdgeTo(Vertex)
.
e
- public void addEdgeTo(Vertex<E> v)
Edge
object which connects this vertex to a given vertex.
v
- - the vertex to connect the one to.public boolean equals(Vertex<E> obj)
v
- - another vertex
public E getData()
public java.util.ArrayList<Edge<E>> getEdges()
public java.util.Set<Vertex<E>> getConnectedVertices()
public Edge<E> getEdgeTo(Vertex<E> v)
null
is returned.
v
- - another vertex.
public Location getLocation()
Location
object for this vertex.public java.util.ArrayList<Vertex<E>> getNeighbors()
public Vertex<E> getOtherEnd(Edge<E> e)
e
- - an edge
public int getValue()
public boolean hasEdgeTo(Vertex<E> v)
v
- - another vertex
public boolean isSelected()
public boolean isVisited()
public void removeEdgeTo(Vertex<E> v)
v
- - another vertexpublic void removeAllEdges()
public void setData(E data)
public void setLocation(Location location)
location
- - a new Location
public void setSelected(boolean isSelected)
isSelected
- - a new selection valuepublic void setValue(int value)
value
- - new integer value.public void setVisited(boolean isVisited)
isVisited
-
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |