Distances between the graphs of matrices