The graph is implicit — no adjacency list exists, neighbours are computed by (r±1, c) and (r, c±1). Scan every cell; each time you land on un-sunk land, that is one new island, so sink the whole component before the scan moves on.
before the four calls, not after — mark first, or the neighbours call straight back and the recursion never ends.