Python Depth-first traversal with adjacency list for each initial, O(mn^2) time
Intuition\nVariant of depth-first search\n\n# Approach\n1. Create an adjacency list from adjacency matrix.\n2. For each initially infected node:\n    1. Remove 
# Intuition\nVariant of depth-first search\n\n# Approach\n1. Create an adjacency list from adjacency matrix.\n2. For each initially infected node:\n    1. Remove it from the graph (virtually).\n    2. Traverse the graph once to infect nodes.\n    3. Count the number of nodes infected.\n    4. Maintain the minimum.\n\n# Complexity\nLet m = len(initial).\n\n- Time complexity: $O(mn^2)$\n\n- Space complexity: $O(n^2)$\n\n# Code\n```\nclass Solution:\n    def minMalwareSpread(self, graph: List[List[int]], initial: List[int]) -> int:\n        n = len(graph)\n        adj_list = self.to_adj_list(graph)\n        chosen_node = n\n        min_infected_count = n + 1\n        for remove_node in initial:\n            infected = [False for _ in range(n)]\n            for init in initial:\n                self.infect(init, adj_list, infected, remove_node)\n            infected_count = sum(infected)\n            if infected_count < min_infected_count or \\\n               (infected_count == min_infected_count and remove_node < chosen_node):\n                min_infected_count = infected_count\n                chosen_node = remove_node\n        return chosen_node\n\n        \n    @staticmethod\n    def infect(node: int, adj_list: List[List[int]], infected: List[bool], remove_node: int) -> None:\n        if node != remove_node:\n            infected[node] = 1\n            for neighbor in adj_list[node]:\n                if not infected[neighbor]:\n                    Solution.infect(neighbor, adj_list, infected, remove_node)\n\n\n    @staticmethod\n    def to_adj_list(adj_mat: List[List[int]]) -> List[List[int]]:\n        n = len(adj_mat)\n        adj_list = [[] for _ in range(n)]\n        for i in range(1, n):\n            for j in range(i):\n                if adj_mat[i][j]:\n                    adj_list[i].append(j)\n                    adj_list[j].append(i)\n        return adj_list\n```
['Depth-First Search', 'Python3']