You start with some research.
Shortest path problem - Wikipedia

Then you decide on a data structure to represent " The adjacency list for the graph."