Newer
Older
package INF102.lab5.graph;
import java.util.Set;
public interface IGraph<V> {
/**
* Number of nodes in the graph
* @return number of nodes in graph
*/
public int size();
/**
* A way to iterate through all vertices of this graph
/**
* Add <code>node</code> to graph
* @param node
*/
public void addNode(V node);
/**
* Remove <code>node</code> from graph
* @param node
*/
public void removeNode(V node);
/**
* Add edge between node <code>u</code> and <code>v</code>
* @param u
* @param v
* @throws IllegalArgumentException if the nodes given are not in the graph
*/
public void addEdge(V u, V v);
/**
* Remove edge between node <code>u</code> and <code>v</code>
* @param u
* @param v
*/
public void removeEdge(V u, V v);
/**
* Checks if the given <code>node</code> is in the graph
* @param node
* @return true if node is in graph
*/
public boolean hasNode(V node);
/**
* Checks if two given vertices are adjacent
*
* @return true if both vertices are in the graph and there is an edge between
* them in the graph
public boolean adjacent(V u, V v);
/**
* Finds all neighbours of node <code>u</code>.
* The neighbours of a node is all nodes which it has an edge to.
* @param node
* @return list of all neighbours
*/
public Set<V> neighbours(V node);