package graphs; import java.util.*; public class AdjacencyMatrixGraph { boolean [] [] g; // g[v][w]==true when there is an edge from v to w // constructor goes here // returns a list of nodes of the graph such that if v precedes w in the list, // then there is no edge from w to v // Such a thing is possible if and only if the graph has no cycles // If the graph has cycles, returns null Iterable topologicalSort () { boolean [] removed = new boolean[g.length]; Queue output = new LinkedList(); for (int i = 0; i