V - the type of the verticespublic abstract class Vertex<V extends Vertible<V>> extends Object implements Vertible<V>
Graph,
WeightedGraph| Modifier and Type | Field and Description |
|---|---|
protected V[] |
adjacency
Adjacency list of this vertex.
|
protected int |
index
The index position in the graph.
|
protected String |
name
Name of this vertex.
|
| Constructor and Description |
|---|
Vertex(int index)
Creates a vertex with the specified index which also specifies its name.
|
Vertex(int index,
String name)
Creates a vertex with the specified index and name.
|
Vertex(int index,
String name,
V[] adjacency)
Creates a vertex with the specified index and adjacency list,
whose name equals the index.
|
Vertex(int index,
V[] adjacency)
Creates a vertex with the specified index and adjacency list,
whose name equals the index.
|
Vertex(String name)
Creates a vertex with the specified name.
|
| Modifier and Type | Method and Description |
|---|---|
abstract V |
copy()
Creates and returns a copy of this object.
|
V[] |
getAdjacency()
Returns the adjacency list of this vertex as specified by the weighted
graph it belongs to.
|
double |
getDistance()
Returns the distance of the shortest path from a
specified source to this vertex as determined by the Dijkstra algorithm.
|
int |
getIndex()
Returns the index of this vertex as specified by the weighted graph it belongs to.
|
String |
getName()
Returns the name of this vertex.
|
V |
getPredecessor()
Returns the predecessor of this vertex in the shortest path from a
specified source as determined by the Dijkstra algorithm.
|
boolean |
isInProcess()
Returns a flag if this vertex is in process.
|
boolean |
isMarked()
Returns a flag if this vertex is marked.
|
void |
mark()
Marks this vertex as true.
|
void |
setAdjacency(V[] adjacency)
Sets the adjacency list of this vertex as specified by the weighted
graph it belongs to.
|
void |
setDistance(double distance)
Sets the distance of the shortest path from a
specified source to this vertex as determined by the Dijkstra algorithm.
|
void |
setIndex(int index)
Sets the index of this vertex as specified by the weighted graph it belongs to.
|
void |
setInProcess(boolean inProcess)
Sets this vertex process flag to the specified value.
|
void |
setMarked(boolean marked)
Sets this vertex mark flag to the specified value.
|
void |
setName(String name)
Sets the name of this vertex as specified by the weighted graph it belongs to.
|
void |
setPredecessor(V predecessor)
Sets the predecessor of this vertex in the shortest path from a
specified source as determined by the Dijkstra algorithm.
|
String |
toString() |
protected String name
protected int index
public Vertex(int index)
index - the index of this vertexpublic Vertex(String name)
name - the name of this vertexpublic Vertex(int index,
String name)
index - the index of this vertexname - the name of this vertexpublic Vertex(int index,
V[] adjacency)
index - the index of this vertexadjacency - the adjacency list of this vertexpublic abstract V copy()
x.clone() != x is true,.public void setName(String name)
public String getName()
public int getIndex()
public void setIndex(int index)
public V[] getAdjacency()
getAdjacency in interface Vertible<V extends Vertible<V>>public void setAdjacency(V[] adjacency)
setAdjacency in interface Vertible<V extends Vertible<V>>adjacency - the adjacency list this vertexpublic V getPredecessor()
getPredecessor in interface Vertible<V extends Vertible<V>>public void setPredecessor(V predecessor)
setPredecessor in interface Vertible<V extends Vertible<V>>predecessor - the predecessor of this vertex in the shortest pathWeightedGraphpublic double getDistance()
getDistance in interface Vertible<V extends Vertible<V>>WeightedGraphpublic void setDistance(double distance)
setDistance in interface Vertible<V extends Vertible<V>>distance - the distance of this vertex in the shortest pathpublic void mark()
public void setMarked(boolean marked)
public boolean isMarked()
public boolean isInProcess()
isInProcess in interface Vertible<V extends Vertible<V>>true if and only this vertex is markedpublic void setInProcess(boolean inProcess)
setInProcess in interface Vertible<V extends Vertible<V>>inProcess - flag which marks this vertex