Implemented counting of rows and columns (required to compute the neighbors of each vertex)