I ran your solution code against leetcode 924 and it failed for 1 unit test:
graph: [[1,0,0,0,0,0,0,1,1,1],[0,1,1,0,0,1,0,0,0,0],[0,1,1,1,0,0,1,0,0,0],[0,0,1,1,0,1,1,0,0,0],[0,0,0,0,1,0,0,1,0,1],[0,1,0,1,0,1,1,0,0,0],[0,0,1,1,0,1,1,0,0,0],[1,0,0,0,1,0,0,1,0,1],[1,0,0,0,0,0,0,0,1,1],[1,0,0,0,1,0,0,1,1,1]]
initial: [2,4]
Expected answer: 2
Actual answer: 4
Course: Grokking Coding Interview Patterns in Java - Learn Interactively
Lesson: Solution: Minimize Malware Spread