@Override
	public V opposite(V vertex, E edge) {

		// Check that both the edge and vertex are in our graph.
		if (vertex == null || edge == null || !vertices.contains(vertex)
				|| !edges.contains(edge)) {
			return null;
		}

		// Get the vertices for the edge.
		Set<V> vertices = edgesToVertices.get(edge);

		if (vertices.contains(vertex)) {
			// We know this was a valid search. Return the opposite vertex.
			Iterator<V> iter = vertices.iterator();
			while (iter.hasNext()) {
				V v = iter.next();
				if (!v.equals(vertex)) {
					return v;
				}
			}
		}

		return null;
	}