added adjacency matrix construction