DirectedGraph { public Set<T> getInboundNodes(T node) { return get(_inboundEdges, node, false); } 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 testGetInboundNodes() { DirectedGraph<String> graph = new DirectedGraph<String>(); graph.addNode("b"); Set<String> n1 = graph.getInboundNodes("b"); assertEquals(0, n1.size()); graph.addEdge("a", "b"); Set<String> n2 = graph.getInboundNodes("b"); assertEquals(1, n2.size()); assertTrue(n2.contains("a")); Set<String> n3 = graph.getInboundNodes("a"); assertEquals(0, n3.size()); graph.addEdge("b", "b"); Set<String> n4 = graph.getInboundNodes("b"); assertEquals(2, n4.size()); assertTrue(n4.contains("a")); assertTrue(n4.contains("b")); }