ds: update graph adjacent matrix