Find the shortest path

i want to create a object that can find the shortest path to use. example, there is a(x,y), b(x,y), c(x,y), d(x,y). This object will check the a,b,c,d to find out the shortest or nearest, and then go to that location. Any function to use? or any logic to recommend? thanks for reply.