using a matrix to represent a graph