Amazon interview question

OOP design DSA question regarding graphs (Dijkstra),