Python 9 lines O(kn^2) BFS
\n# Code\n\nclass Solution:\n    # the key observation for me is the fact that we don\'t need to\n    # really delete the initial in the graph. We can simply ig
\n# Code\n```\nclass Solution:\n    # the key observation for me is the fact that we don\'t need to\n    # really delete the initial in the graph. We can simply ignore\n    # the deleted initial while we are doing BFS. So basically we\n    # do BFS with each deleted value on initial, and we get the\n    # minimal count of the connected graph. Note if two deleted\n    # values give same count of connected graph, then we choose\n    # smaller value. that\'s why I used a tuple, (BFS(a), a) this \n    # will first compare BFS(a), if they are equal then it compares\n    # a.\n    def minMalwareSpread(self, graph: List[List[int]], initial: List[int]) -> int:\n        def BFS(delval):\n            seen, lst = set(), list(initial)\n            while lst:\n                node = lst.pop()\n                if node == delval or node in seen: continue\n                seen.add(node)\n                lst += [i for i, val in enumerate(graph[node]) if val]\n            return len(seen)\n        return min(initial, key=lambda a: (BFS(a), a))\n            \n```
['Python3']