Added method to generate adjacency matrix