python3 bfs from every initial
\n# Code\n\nclass Solution:\n    def minMalwareSpread(self, graph: List[List[int]], initial: List[int]) -> int:\n        edges = defaultdict(list)\n        init
\n# Code\n```\nclass Solution:\n    def minMalwareSpread(self, graph: List[List[int]], initial: List[int]) -> int:\n        edges = defaultdict(list)\n        initial.sort()\n        for r in range(len(graph)):\n            for c in range(len(graph)):\n                if r == c:\n                    continue\n                if graph[r][c]:\n                    edges[r].append(c)\n                    edges[c].append(r)\n\n        node = inf\n        final = inf\n        for i in range(len(initial)):\n            i = initial[i]\n            visited = set([i])\n            dfs = []\n            for a in initial:\n                if a not in visited:\n                    dfs.append(a)\n            \n            while dfs:\n                k = dfs.pop()\n                visited.add(k)\n                for e in edges[k]:\n                    if e not in visited:\n                        visited.add(e)\n                        dfs.append(e)\n            \n            if len(visited)-1 < final:\n                final = len(visited)-1\n                node = i\n            \n\n        return node\n\n\n\n```
['Python3']