This is written in coefficient form as
$$uf_{i,j-1} + cf_{i-1,j} + af_{i,j} + cf_{i+1,j} + uf_{i,j+1} = b_{i,j}.$$Grid B
One iteration consists of sweeping lines (1), (2), and (3) on Grid A, followed by sweeping lines (1), (2), and (3) on Grid B.
Matricies are setup in the usual fashion, with decoupled points on the RHS, and boundary conditions properly specified.
For parabolic problems, Hoffman gives an ADI alternative.
$$\frac{\color{blue}{f_{i,j}^{n+1}}-f_{i,j}^n}{\Delta t} = \alpha\color{blue}{\left(\frac{\partial^2f}{\partial x^2}\right)_{i,j}^{n+1} + } \alpha\left(\frac{\partial^2f}{\partial y^2}\right)_{i,j}^n + S_{i,j}^n,$$
$$\frac{\color{blue}{f_{i,j}^{n+2}}-f_{i,j}^{n+1}}{\Delta t} = \alpha\left(\frac{\partial^2f}{\partial x^2}\right)_{i,j}^{n+1} + \alpha\color{blue}{\left(\frac{\partial^2f}{\partial y^2}\right)_{i,j}^{n+2}} + S_{i,j}^{n+1}.$$