Tools for processing adjacency matrix