DirectedGraph { public Map<V, Integer> outDegree() { Map<V, Integer> result = new HashMap<>(); for (V vertex : neighbors.keySet()) { result.put(vertex, neighbors.get(vertex).size()); } return result; }  void addVertex(V vertex); boolean containsVertex(V vertex); void removeVertex(V vertex); void addEdge(V from, V to); void removeEdge(V from, V to); List<V> getNeighbors(V vertex); Map<V, Integer> outDegree(); Map<V, Integer> inDegree(); List<V> topologicalSort(); List<V> reverseTopologicalSort(); boolean isDag(); @Override String toString();  }
@Test public void outDegree() { Map<Character, Integer> result = graph.outDegree(); Map<Character, Integer> expected = new HashMap<>(7); expected.put('A', 1); expected.put('B', 2); expected.put('C', 0); expected.put('D', 1); expected.put('E', 0); expected.put('F', 1); expected.put('G', 0); assertEquals(expected, result); }