java bfs without copy graph
the key thing is to identify the nodes that can be uniquely sourced by any initial nodes\ndetails (in chinese)\nhttp://www.noteanddata.com/leetcode-928-Minimize
the key thing is to identify the nodes that can be uniquely sourced by any initial nodes\ndetails (in chinese)\nhttp://www.noteanddata.com/leetcode-928-Minimize-Malware-Spread-II-java-solution-note-2.html\nto achieve unique, we can skip the initial nodes in the bfs and also use a set to record the source and remove if it already exist in the set. \n\n```\npublic int minMalwareSpread(int[][] graph, int[] initial) {\n    Set<Integer> initialSet = new HashSet<>();\n    for(int node: initial) {\n        initialSet.add(node);\n    }\n    Map<Integer,Integer> uniqueSourceMap = new HashMap<>();\n    Set<Integer> uniqueSourceSet = new HashSet<>();\n    for(int node: initial) {\n        Set<Integer> visited = new HashSet<>();\n        Queue<Integer> queue = new LinkedList<>();\n        queue.add(node);\n        while(queue.size() > 0) {\n            int v = queue.poll();\n            visited.add(v);\n\n            if(!uniqueSourceSet.contains(v)) {\n                uniqueSourceSet.add(v);                    \n                uniqueSourceMap.put(v, node);\n            }\n            else {\n                uniqueSourceMap.remove(v);\n            }\n\n            for(int i = 0; i < graph.length; ++i) {\n                if(graph[v][i] == 1 && !initialSet.contains(i) && !visited.contains(i)) {\n                    queue.add(i);                        \n                }\n            }\n        }\n    }\n    int[] countTable = new int[graph.length];\n    int maxi = 0;\n    \n    for(Map.Entry<Integer, Integer> entry: uniqueSourceMap.entrySet()) {\n        int i = entry.getValue();\n        countTable[i]++;            \n        if(countTable[i] > countTable[maxi]) maxi = i;\n        else if(countTable[i] == countTable[maxi] && i < maxi) maxi = i;            \n    }\n    return maxi;\n}\n\n```
[]