def findCircleNum(self, M):
        """
        :type M: List[List[int]]
        :rtype: int
        """
        # because
        visited = [0] * len(M)
        count = 0
        for i in range(len(M)):
            if visited[i] == 0:
                self.dfs(M, visited, i)
                count += 1
        return count

        :type M: List[List[int]]
        :rtype: int
        
python/547_Friend_Circles.py