change format Matrix -> AdjacencyList