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;
	}
Returns all source vertices (those with no incoming edges) in the graph.

@param g the graph
@return source vertices
Ghidra/Framework/Graph/src/main/java/ghidra/graph/GraphAlgorithms.java