Write a function to find the shortest path in a network grid, explaining your choice of data structure.