Finding the shortest path through a maze using graph theory