Delete/Modify a cell in a UnstructuredGrid

I have an UnstructuredGrid that consists of a collection of square cells. Given an id of a particular cell I would like to either (assume that the ids for the points defining this cell are p_0,p_1,p_2,p_3)

a) delete that cell and replace it with a new triangular cell defined by p_0,p_1,p_2; or
b) modify the cell such that new cell is triangular defined by p_0,p_1,p_2

If I was dealing with a PolyData object then I believe that I can delete a cell as follows


and then simply add in a new cell with the appropriate properties. But how do I do this with an UnstructuredGrid? An answer using C++ or Python would be great.