For this Question: For a directed acyclic graph (DAG), a topological ordering is a linear ordering of its vertices such that for every directed edge from vertex u to vertex v, u is listed before v.

Given a DAG find the Lexicographically smallest topological ordering.The first line consists of two space-separated integers denoting N and M.
Each of the following M lines consists of two space-separated integers X and Y denoting there is an edge from X directed toward Y.


<b>Constraints</b>
1<=N, M<=200000
1<=X, Y<=NPrint N space separated integers denoting the topological sort.Sample Input
5 6
1 2
1 3
2 3
2 4
3 4
3 5

Sample Output
1 2 3 4 5 , I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
    static ArrayList<ArrayList<Integer>> adj;


    static void graph(int v){
        adj =new ArrayList<>();
        for(int i=0;i<=v;i++) adj.add(new ArrayList<Integer>());
    }


    static void addedge(int u, int v){
        adj.get(u).add(v);
    }

    static void topo(int n){
        int res[] = new int[n];
        PriorityQueue<Integer> q = new PriorityQueue<>();
        int indegree[] = new int[n];
        for(int i=0;i<n;i++) for(int it: adj.get(i)) indegree[it]++;
        for(int i=0;i<n;i++) if(indegree[i]==0) q.add(i);
        int idx = 0;
        while(!q.isEmpty()){
            int tmp = q.poll();
            res[idx++] = tmp;
            for(int it: adj.get(tmp)){
                indegree[it]--;
                if(indegree[it]==0) q.add(it);
            }
        }
        for(int i=0;i<n;i++) System.out.print((res[i]+1)+" ");
    }
    public static void main (String[] args) throws Exception{
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String t[] = br.readLine().split(" ");
        int n = Integer.parseInt(t[0]);
        graph(n);
        int e = Integer.parseInt(t[1]);
        for(int i=0;i<e;i++) {
            String num[] = br.readLine().split(" ");
            int u = Integer.parseInt(num[0]);
            int v = Integer.parseInt(num[1]);
            addedge(u-1, v-1);
        }

        topo(n);
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?