graph: code cleanup in adjacency matrix