modify block graph algo