The mathIT Library
A Java™ API for mathematics
org.mathIT.graphs

## Class Vertex<V extends Vertible<V>>

• Type Parameters:
`V` - the type of the vertices
All Implemented Interfaces:
Vertible<V>
Direct Known Subclasses:
Actor, SimpleVertex

```public abstract class Vertex<V extends Vertible<V>>
extends Object
implements Vertible<V>```
An instance of this class represents a vertex of a graph.
Version:
1.1
Author:
Andreas de Vries
`Graph`, `WeightedGraph`
• ### Field Summary

Fields
Modifier and Type Field and Description
`protected V[]` `adjacency`
`protected int` `index`
The index position in the graph.
`protected String` `name`
Name of this vertex.
• ### Constructor Summary

Constructors
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.
• ### Method Summary

All Methods
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()`
• ### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`
• ### Field Detail

• #### name

`protected String name`
Name of this vertex.
• #### index

`protected int index`
The index position in the graph.

`protected V extends Vertible<V>[] adjacency`
Adjacency list of this vertex. It contains all vertices connected to it by an edge.
• ### Constructor Detail

• #### Vertex

`public Vertex(int index)`
Creates a vertex with the specified index which also specifies its name.
Parameters:
`index` - the index of this vertex
• #### Vertex

`public Vertex(String name)`
Creates a vertex with the specified name.
Parameters:
`name` - the name of this vertex
• #### Vertex

```public Vertex(int index,
String name)```
Creates a vertex with the specified index and name.
Parameters:
`index` - the index of this vertex
`name` - the name of this vertex
• #### Vertex

```public Vertex(int index,
Creates a vertex with the specified index and adjacency list, whose name equals the index.
Parameters:
`index` - the index of this vertex
`adjacency` - the adjacency list of this vertex
• #### Vertex

```public Vertex(int index,
String name,
Creates a vertex with the specified index and adjacency list, whose name equals the index.
Parameters:
`index` - the index of this vertex
`name` - the name of this vertex
`adjacency` - the adjacency list of this vertex
• ### Method Detail

• #### copy

`public abstract V copy()`
Creates and returns a copy of this object. For any object x, the expression `x.clone() != x` is true,.
Specified by:
`copy` in interface `Vertible<V extends Vertible<V>>`
Returns:
a clone of this object
• #### setName

`public void setName(String name)`
Sets the name of this vertex as specified by the weighted graph it belongs to. The index has to be consistent with the weight matrix of the weighted graph.
Specified by:
`setName` in interface `Vertible<V extends Vertible<V>>`
Parameters:
`name` - the name of this vertex in the weighted graph
• #### getName

`public String getName()`
Returns the name of this vertex.
Specified by:
`getName` in interface `Vertible<V extends Vertible<V>>`
Returns:
the name of this vertex
• #### getIndex

`public int getIndex()`
Returns the index of this vertex as specified by the weighted graph it belongs to. The index has to be consistent with the weight matrix of the weighted graph.
Specified by:
`getIndex` in interface `Vertible<V extends Vertible<V>>`
Returns:
the name of this vertex
• #### setIndex

`public void setIndex(int index)`
Sets the index of this vertex as specified by the weighted graph it belongs to. The index has to be consistent with the weight matrix of the weighted graph.
Specified by:
`setIndex` in interface `Vertible<V extends Vertible<V>>`
Parameters:
`index` - the index of this vertex in the weighted graph

`public V[] getAdjacency()`
Returns the adjacency list of this vertex as specified by the weighted graph it belongs to. The adjacency list has to be consistent with the weight matrix of the weighted graph.
Specified by:
`getAdjacency` in interface `Vertible<V extends Vertible<V>>`
Returns:

`public void setAdjacency(V[] adjacency)`
Sets the adjacency list of this vertex as specified by the weighted graph it belongs to. The adjacency list has to be consistent with the weight matrix of the weighted graph.
Specified by:
`setAdjacency` in interface `Vertible<V extends Vertible<V>>`
Parameters:
`adjacency` - the adjacency list this vertex
• #### getPredecessor

`public V getPredecessor()`
Returns the predecessor of this vertex in the shortest path from a specified source as determined by the Dijkstra algorithm.
Specified by:
`getPredecessor` in interface `Vertible<V extends Vertible<V>>`
Returns:
the predecessor of this vertex in the shortest path
• #### setPredecessor

`public void setPredecessor(V predecessor)`
Sets the predecessor of this vertex in the shortest path from a specified source as determined by the Dijkstra algorithm.
Specified by:
`setPredecessor` in interface `Vertible<V extends Vertible<V>>`
Parameters:
`predecessor` - the predecessor of this vertex in the shortest path
`WeightedGraph`
• #### getDistance

`public double getDistance()`
Returns the distance of the shortest path from a specified source to this vertex as determined by the Dijkstra algorithm.
Specified by:
`getDistance` in interface `Vertible<V extends Vertible<V>>`
Returns:
the distance of this vertex in the shortest path
`WeightedGraph`
• #### setDistance

`public void setDistance(double distance)`
Sets the distance of the shortest path from a specified source to this vertex as determined by the Dijkstra algorithm.
Specified by:
`setDistance` in interface `Vertible<V extends Vertible<V>>`
Parameters:
`distance` - the distance of this vertex in the shortest path
• #### mark

`public void mark()`
Marks this vertex as true. The mark is designed to be utilized as a temporary and dynamic attribute for algorithms.
Specified by:
`mark` in interface `Vertible<V extends Vertible<V>>`
• #### setMarked

`public void setMarked(boolean marked)`
Sets this vertex mark flag to the specified value. The mark is designed to be utilized as a temporary and dynamic attribute for algorithms.
Specified by:
`setMarked` in interface `Vertible<V extends Vertible<V>>`
Parameters:
`marked` - flag which marks this vertex
• #### isMarked

`public boolean isMarked()`
Returns a flag if this vertex is marked. The flag is designed to be utilized as a temporary and dynamic attribute for algorithms.
Specified by:
`isMarked` in interface `Vertible<V extends Vertible<V>>`
Returns:
`true` if and only this vertex is marked
• #### isInProcess

`public boolean isInProcess()`
Returns a flag if this vertex is in process. The flag is designed to be utilized as a temporary and dynamic attribute for algorithms.
Specified by:
`isInProcess` in interface `Vertible<V extends Vertible<V>>`
Returns:
`true` if and only this vertex is marked
• #### setInProcess

`public void setInProcess(boolean inProcess)`
Sets this vertex process flag to the specified value. The flag is designed to be utilized as a temporary and dynamic attribute for algorithms.
Specified by:
`setInProcess` in interface `Vertible<V extends Vertible<V>>`
Parameters:
`inProcess` - flag which marks this vertex
• #### toString

`public String toString()`
Overrides:
`toString` in class `Object`