write apsp matrix after other stats calculations, and fix its timing