DirectedGraph { public Set<T> getNodes() { Set<T> nodes = new HashSet<T>(); nodes.addAll(_outboundEdges.keySet()); nodes.addAll(_inboundEdges.keySet()); return nodes; } DirectedGraph();  DirectedGraph(DirectedGraph<T> graph); Set<T> getNodes(); Set<Pair<T>> getEdges(); Set<T> getInboundNodes(T node); Set<T> getOutboundNodes(T node); boolean isConnected(T from, T to); void addNode(T node); void addEdge(T from, T to); void removeEdge(T from, T to); List<T> getTopologicalSort(Comparator<T> tieBreaker);  }
@Test public void testGetNodes() { DirectedGraph<String> graph = new DirectedGraph<String>(); Set<String> n0 = graph.getNodes(); assertEquals(0, n0.size()); graph.addNode("a"); Set<String> n1 = graph.getNodes(); assertEquals(1, n1.size()); assertTrue(n1.contains("a")); graph.addNode("b"); Set<String> n2 = graph.getNodes(); assertEquals(2, n2.size()); assertTrue(n2.contains("a")); assertTrue(n2.contains("b")); graph.addNode("b"); n2 = graph.getNodes(); assertEquals(2, n2.size()); assertTrue(n2.contains("a")); assertTrue(n2.contains("b")); graph.addNode("c"); Set<String> n3 = graph.getNodes(); assertEquals(3, n3.size()); assertTrue(n3.contains("a")); assertTrue(n3.contains("b")); assertTrue(n3.contains("c")); }