public class Vertex<V> extends Observable implements Comparable<Vertex<V>>, Cloneable
vertexInfo(v)
Modifier and Type | Class and Description |
---|---|
static class |
Vertex.Event |
Modifier and Type | Field and Description |
---|---|
V |
extraData |
static double |
MAX_COST
Maximum possible cost to reach a vertex from another; treat this as "infinity".
|
Constructor and Description |
---|
Vertex(String name)
Constructs information for the given vertex.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Resets the previous, visited, cost, and number data fields to their original values.
|
void |
clear(boolean clearExtraData)
Resets the previous, visited, cost, and number data fields to their original values.
|
Vertex<V> |
clone()
Returns a copy of this Vertex as per the contract of the Object.clone method.
|
Color |
color()
Returns color of vertex
|
int |
compareTo(Vertex<V> o) |
double |
cost()
Returns the value of the internal 'cost' to reach this vertex.
|
boolean |
equals(Object o)
Returns true if o refers to a Vertex object correspending to the same
underlying 'V' object as this one.
|
int |
hashCode()
Returns an integer code for placing this vertex into a hash-based collection.
|
String |
name()
Returns the vertex's name.
|
void |
notifyObservers() |
void |
notifyObservers(Object arg) |
int |
number()
Returns the value of the internal 'number' vertex marker for this vertex.
|
Vertex<V> |
previous()
Returns the value of the internal 'previous' vertex marker for this vertex.
|
void |
setColor(Color color)
Sets the vertex's color
|
void |
setCost(double cost)
Sets the value of the internal 'cost' to reach this vertex.
|
void |
setNumber(int number)
Sets the value of the internal 'number' vertex marker for this vertex.
|
void |
setPrevious(Vertex<V> previous)
Sets the value of the internal 'previous' vertex marker for this vertex.
|
void |
setVisited()
Sets the value of the internal 'previous' vertex marker to true for this vertex.
|
void |
setVisited(boolean visited)
Sets the value of the internal 'previous' vertex marker for this vertex.
|
String |
toString()
Returns a string representation of the information about this vertex.
|
boolean |
visited()
Returns the value of the internal 'visited' vertex marker for this vertex.
|
addObserver, clearChanged, countObservers, deleteObserver, deleteObservers, hasChanged, setChanged
public static final double MAX_COST
public V extraData
public Vertex(String name)
v
- The vertex this information is about.NullPointerException
- If the vertex is null.public void clear()
public void clear(boolean clearExtraData)
public Vertex<V> clone()
public Color color()
public int compareTo(Vertex<V> o)
compareTo
in interface Comparable<Vertex<V>>
public double cost()
public boolean equals(Object o)
public int hashCode()
public String name()
public void notifyObservers()
notifyObservers
in class Observable
public void notifyObservers(Object arg)
notifyObservers
in class Observable
public int number()
public Vertex<V> previous()
public void setColor(Color color)
public void setCost(double cost)
cost
- the new cost to usepublic void setNumber(int number)
number
- the new number to usepublic void setPrevious(Vertex<V> previous)
public void setVisited()
public void setVisited(boolean visited)
public boolean visited()