Fix adjacency matrix operations