Python - DFS Connected Components
\nclass Solution(object):\n    def findCircleNum(self, M):\n        """\n        :type M: List[List[int]]\n        :rtype: int\n        """\n        circles = 0
```\nclass Solution(object):\n    def findCircleNum(self, M):\n        """\n        :type M: List[List[int]]\n        :rtype: int\n        """\n        circles = 0\n        length = len(M)\n        visited = [False] * length\n\n        def dfs(person):\n            if visited[person]: return\n            visited[person] = True\n            for friend, is_friend in enumerate(M[person]):\n                if is_friend and not visited[friend]:\n                    dfs(friend)\n\n        for person in xrange(length):\n            if visited[person]: continue\n            circles += 1\n            dfs(person)\n            \n        return circles\n```
['Depth-First Search', 'Python']