Depth first search using adjacency matrix