Simple Java Solution
Code\njava []\nclass Solution {\n    public int minMalwareSpread(int[][] graph, int[] initial) {\n        int result=graph.length;\n        int min=graph.length
# Code\n```java []\nclass Solution {\n    public int minMalwareSpread(int[][] graph, int[] initial) {\n        int result=graph.length;\n        int min=graph.length;\n    for(int i=0;i<initial.length;i++)\n    {\n        Queue<Integer> q=new LinkedList<Integer>();\n        HashSet<Integer> hset=new HashSet<Integer>();\n        hset.add(initial[i]);\n        for(int j=0;j<initial.length;j++)\n        {\n            if(j==i)\n            {\n                continue;\n            }\n           q.add(initial[j]);\n           hset.add(initial[j]);\n        }\n         int count=0;\n        while(q.size()>0)\n        {\n            int x=q.poll();\n            count++;\n           for(int k=0;k<graph[0].length;k++)\n           {\n              if(graph[x][k]==1 && !hset.contains(k))\n              {\n                q.add(k);\n                hset.add(k);\n              }\n           }\n\n        }\n         if(count==min)\n           {\n            result=Math.min(result,initial[i]);\n            min=count;\n           }\n           else if(count<min)\n           {\n            result=initial[i];\n            min=count;\n           }\n    }\n    return result;\n}\n}\n```
['Java']