package net.berack.upo.graph;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Objects;
import java.util.function.Consumer;
import net.berack.upo.Graph;
import net.berack.upo.graph.visit.VisitInfo;
/**
* Class used for represent a vertex of the graph.
* The vertex contained is linked with the graph, so if any changes are made to
* it, then they will be reflected here.
*
* @param the vertex
* @author Berack96
*/
public class Vertex {
public static final String REMOVED = "The vertex is no longer in the graph";
/**
* The vertex associated
*/
private final V vertex;
/**
* The graph associated
*/
private final Graph graph;
/**
* Get a Vertex linked with the graph
*
* @param graph the graph of the vertex
* @param vertex the vertex
* @throws NullPointerException if one of the param is null
*/
public Vertex(Graph graph, V vertex) throws NullPointerException {
if (graph == null || vertex == null)
throw new NullPointerException();
this.graph = graph;
this.vertex = vertex;
}
/**
* Get the vertex
*
* @return the vertex
*/
public V get() {
return vertex;
}
/**
* Mark the vertex with the associated string
*
* @param mark the marker
* @throws NullPointerException if the marker is null
* @throws UnsupportedOperationException if the vertex is not in the graph anymore
*/
public void mark(Object mark) throws NullPointerException, UnsupportedOperationException {
throwIfNotContained();
graph.mark(vertex, mark);
}
/**
* Remove the specified mark from this vertex
*
* @param mark the marker
* @throws NullPointerException if the mark is null
* @throws UnsupportedOperationException if the vertex is not in the graph anymore
*/
public void unMark(Object mark) throws UnsupportedOperationException {
throwIfNotContained();
graph.unMark(vertex, mark);
}
/**
* Remove all the marker from the vertex
*
* @throws UnsupportedOperationException if the vertex is not in the graph anymore
*/
public void unMark() throws UnsupportedOperationException {
throwIfNotContained();
graph.unMark(vertex);
}
/**
* Get all the marks that are associated with this vertex
*
* @return a set of marks
* @throws UnsupportedOperationException if the vertex is not in the graph anymore
*/
public Collection