### Question:
GraphAlgorithms { public static <V, E extends GEdge<V>> Set<V> getSources(GDirectedGraph<V, E> g) { Set<V> sources = new HashSet<>(); Collection<V> vertices = g.getVertices(); for (V v : vertices) { Collection<E> inEdges = g.getInEdges(v); if (inEdges.isEmpty()) { sources.add(v); } } return sources; } private  GraphAlgorithms(); static Set<V> getSources(GDirectedGraph<V, E> g); static Set<V> getSinks(GDirectedGraph<V, E> g); static Set<V> getDescendants(GDirectedGraph<V, E> g,
			Collection<V> vertices); static Set<V> getAncestors(GDirectedGraph<V, E> g,
			Collection<V> vertices); static Set<E> getEdgesFrom(GDirectedGraph<V, E> g, V v,
			boolean topDown); static Set<E> getEdgesFrom(GDirectedGraph<V, E> g,
			Collection<V> vertices, boolean topDown); static GDirectedGraph<V, E> createSubGraph(
			GDirectedGraph<V, E> g, Collection<V> vertices); static Set<Set<V>> getStronglyConnectedComponents(
			GDirectedGraph<V, E> g); static Set<V> getEntryPoints(GDirectedGraph<V, E> g); static GDirectedGraph<V, GEdge<V>> findDominanceTree(
			GDirectedGraph<V, E> g, TaskMonitor monitor); static Set<V> findDominance(GDirectedGraph<V, E> g, V from,
			TaskMonitor monitor); static Set<V> findPostDominance(GDirectedGraph<V, E> g, V from,
			TaskMonitor monitor); static List<List<V>> findCircuits(GDirectedGraph<V, E> g,
			TaskMonitor monitor); static List<List<V>> findCircuits(GDirectedGraph<V, E> g,
			boolean uniqueCircuits, TaskMonitor monitor); static List<List<V>> findCircuits(GDirectedGraph<V, E> g,
			boolean uniqueCircuits, TimeoutTaskMonitor monitor); static void findPaths(GDirectedGraph<V, E> g, V start, V end,
			Accumulator<List<V>> accumulator, TaskMonitor monitor); static void findPaths(GDirectedGraph<V, E> g, V start, V end,
			Accumulator<List<V>> accumulator, TimeoutTaskMonitor monitor); static List<V> getVerticesInPostOrder(GDirectedGraph<V, E> g,
			GraphNavigator<V, E> navigator); static List<V> getVerticesInPreOrder(GDirectedGraph<V, E> g,
			GraphNavigator<V, E> navigator); static Map<V, Integer> getComplexityDepth(
			GDirectedGraph<V, E> g); static Set<E> retainEdges(GDirectedGraph<V, E> graph,
			Set<V> vertices); static Set<V> toVertices(Collection<E> edges); static void printGraph(GDirectedGraph<V, E> g, PrintStream ps);  }### Answer:
@Test public void testGetSources() { TestV v1 = vertex(1); TestV v2 = vertex(2); TestV v3 = vertex(2); g.addVertex(v1); g.addVertex(v2); g.addVertex(v3); Set<TestV> sources = GraphAlgorithms.getSources(g); assertEquals(3, sources.size()); g.addEdge(edge(v1, v2)); g.addEdge(edge(v1, v3)); sources = GraphAlgorithms.getSources(g); assertEquals(1, sources.size()); assertEquals("1", id(sources.iterator().next())); g.addEdge(edge(v2, v1)); g.addEdge(edge(v3, v1)); sources = GraphAlgorithms.getSources(g); assertEquals(0, sources.size()); }