BFS
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nfrom collections import defaultdict, deque\n\nclass Solution:\n    def minMalwareSpread(self, graph: List[List[int]], initial: List[int]) -> int:\n        initial_set = set(initial)\n        initial = sorted(initial)\n\n        adj_list = defaultdict(list)\n        for i in range(len(graph)):\n            for j in range(len(graph[0])):\n                if i != j and graph[i][j] == 1:\n                    adj_list[i].append(j)\n \n        \n        def BFS(skip):\n            queue = deque()\n\n            for i in initial:\n                if i != skip:\n                    queue.append(i)\n\n            infection_count = 0\n            seen = set()\n\n            while queue:\n                node = queue.popleft()\n\n                for nei in adj_list[node]:\n                    if nei != skip:\n                        if nei not in seen:\n                            if nei not in initial_set:\n                                infection_count += 1\n                                queue.append(nei)\n                                seen.add(nei)\n\n            return infection_count\n\n        prev = float(\'inf\')\n        idx = 0\n\n        for i in initial:\n            Curr_infections = BFS(i)\n             \n\n            if Curr_infections < prev:\n                idx = i\n                prev = Curr_infections\n        \n        return idx\n```
['Python3']