Java soln using dfs [If any help needed just comment]
\nclass Solution {\n    static class Edge{\n        int src;\n        int dest;\n        Edge(int s,int d){\n            this.src=s;\n            this.dest=d;\n
```\nclass Solution {\n    static class Edge{\n        int src;\n        int dest;\n        Edge(int s,int d){\n            this.src=s;\n            this.dest=d;\n        }\n    }\n    public int findCircleNum(int[][] isConnected) {\n        ArrayList<Edge> graph[]=new ArrayList[isConnected.length];\n        for(int i=0;i<isConnected.length;i++){\n            graph[i]=new ArrayList<>();\n        }\n        //graph creation\n        for(int i=0;i<isConnected.length;i++){\n            for(int j=0;j<isConnected[0].length;j++){\n                if(isConnected[i][j]==1){\n                   graph[i].add(new Edge(i,j));\n                }       \n            }\n        }\n        int prov=0;\n        boolean vist[]=new boolean[graph.length];\n        for(int i=0;i<graph.length;i++){\n            if(!vist[i]){\n                prov++;\n                dfsUtil(graph, vist,i);\n            }\n        }\n        return prov;\n        \n    }\n    public static void dfsUtil(ArrayList<Edge> graph[],boolean vist[],int curr){ //O(V+E)\n        //visit\n        vist[curr]=true;\n        //call for neighbours\n        for(int i=0;i<graph[curr].size();i++){\n            Edge e=graph[curr].get(i);\n            if(!vist[e.dest]){\n                dfsUtil(graph, vist, e.dest);\n            }\n        }\n    }\n}\n```
['Depth-First Search', 'Graph', 'Java']