Specifically I intend to move a node to some random number of nodes (the coordinates of nodes to be visited may be located from an array), but the moving path must be shortest. The source (moving node) starts from (0, 0).
The shortest path in a grid consists into adding horizontal edges or vertical edges to fill the gap between the two pairs of coordinates. The lenth of the shortest path is the sum of the absolute values of the coordinates. You don't need the Dijkstra machinery. You can arbitrarily alternate horizontal and vertical edges, or first choose to fill first the horizontal gap and then the vertical gap, or vice versa.