For this Question: Print the number of connected components using scipy csgraph1st line: Number of nodes
Next n lines: Adjacency matrixNumber of componetsInput: 
3
0 1 2
1 0 0
2 0 0

Output:
1, I have written this Solution Code: import java.io.*;
import java.util.*;



class Main {
    public static void main (String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);


        int n = sc.nextInt();
        mat = new ArrayList<>();
        for(int i=0; i<n; i++) mat.add(new ArrayList<>());

        for(int i=0;i<n;i++){


            for(int j =0; j < n; j++) {
                int x = sc.nextInt();
                if(x != 0) {
                    mat.get(i).add(j);
                    mat.get(j).add(i);

                }
            }
        }

        boolean vis[] = new boolean[n];
        int cc = 0;
        for(int i=0; i<n; i++){
            if(!vis[i]){
                dfs(i,vis);
                cc++;
            }
        }
        System.out.print(cc);
    }
    static ArrayList<ArrayList<Integer>> mat;
    static void dfs(int ind, boolean[] vis) {
        if(vis[ind]) return;
        vis[ind] = true;
        for(int x: mat.get(ind)){
            if(!vis[x]) dfs(x,vis);
        }
    }
}, In this Programming Language: Java, Now tell me if this Code is compilable or not?