C# Solution
```\npublic int FindCircleNum(int[,] M) {\n        int result = 0;\n        bool[] visited = new bool[M.GetLength(0)];\n        \n        for (int i = 0; i <= M
```\npublic int FindCircleNum(int[,] M) {\n        int result = 0;\n        bool[] visited = new bool[M.GetLength(0)];\n        \n        for (int i = 0; i <= M.GetLength(0) - 1; i++)\n            if(!visited[i])\n            {\n                DFS(i, M, visited);\n                result++;\n            }\n            \n        return result;\n    }\n    \n    private void DFS(int startNode, int[,] graph, bool[] visited)\n    {\n        visited[startNode] = true;\n        \n        for (int i = 0; i <= graph.GetLength(1) - 1; i++)\n        {\n            if (startNode == i)\n                continue;\n            \n            if (graph[startNode, i] == 1 && !visited[i])\n                DFS(i, graph, visited);\n        }\n    }
[]