Implementing DequeAdder

We can use anonymous classing to create objects that add to either the head or tail of a double-ended queue:

        DequeAdder tailAdder = new DequeAdder() {
            public void add(Vertex vertex, Deque<Vertex> deque) {
                deque.addLast(vertex);
            }
        };

        DequeAdder headAdder = new DequeAdder() {
            public void add(Vertex vertex, Deque<Vertex> deque) {
                deque.addFirst(vertex);
            }
        };

tailAdder is used to implement BFS.

headAdder is used to implement DFS.