Topological Sort Code - Graphs
import java.util.*; // A Graph Node class GraphNode{ String name; // list we use in adjacency list ArrayList<GraphNode> neighbours; // Constructor GraphNode(String name){ this.name = name; this.neighbours = new ArrayList<>(); } } public class Main { ArrayList<GraphNode> nodesList; // constructor Main(){ this.nodesList = new ArrayList<>(); } // function to add a directed edge from i->j public void addDirectedAcyclicEdge(int source, int destination){ if(source==destination){ System.out.println("Can't add cyclic edge in graph, as for topological sort the graph...