Dijkstra is an heuristic that check all the possible strokes, depth by depth. It will be the slower heuristic but it will always give the smaller strokes result
This graphic show the depth of all evaluated branches.
The differents colors represent each moves as:
Right
Left
Up
Down
The Arrival branch is the grey one with red dots. Each dot is a strokes and the length is display at the end of the branch.