Let IP be the infection probability matrix with the element at position (u, v) being ip(u, v).