Shortest paths in a divisor graph Introduction

In this challenge, we will be dealing with a certain infinite undirected graph, which I call the high divisor graph.
Its nodes are the integers starting from 2.
There is an edge between two nodes a &lt; b if a divides b and a2 &ge; b.
The subgraph formed by the range from 2 to 18 looks like this:

16-8 12 18
  \|/ |/|
   4  6 9 10 15 14
   |  |/   |/   |
   2  3    5    7  11 13 17


It can be shown that the infinite high divisor graph is connected, so we can ask about the shortest path between two nodes.

Input and output

Your inputs are two integers a and b.
You can assume that 2 &le; a &le; b &lt; 1000.
Your output is the length of the shortest path between a and b in the infinite high divisor graph.
This means the number of edges in the path.

You may find the following fact useful: there always exists an optimal path from a to b that's first increasing and then decreasing, and only visits nodes that are strictly less than 2b2.
In particular, since b &lt; 1000 you only need to consider nodes less than 2 000 000.

Examples

Consider the inputs 3 and 32.
One possible path between the nodes 3 and 32 is

3 -- 6 -- 12 -- 96 -- 32


This path has four edges, and it turns out there are no shorter paths, so the correct output is 4.

As another example, an optimal path for 2 and 25 is

2 -- 4 -- 8 -- 40 -- 200 -- 25


so the correct output is 5.
In this case, no optimal path contains the node 50 = lcm(2, 25).

Rules and scoring

You can write a full program or a function.
The lowest byte count wins, and standard loopholes are disallowed.
There are no time or memory limits, so brute forcing is allowed.

Test cases

2 2 -&gt; 0
2 3 -&gt; 4
2 4 -&gt; 1
2 5 -&gt; 5
3 5 -&gt; 4
6 8 -&gt; 2
8 16 -&gt; 1
12 16 -&gt; 2
16 16 -&gt; 0
2 25 -&gt; 5
3 32 -&gt; 4
2 256 -&gt; 3
60 77 -&gt; 3
56 155 -&gt; 3
339 540 -&gt; 2
6 966 -&gt; 4
7 966 -&gt; 2
11 966 -&gt; 4
2 997 -&gt; 7
991 997 -&gt; 4
Matlab, 218 190 175 bytes
function f(a,b);q=a;l(b)=0;l(a)=1;while~l(b);x=q(1);q=q(2:end);l(end+1:x^2)=0;g=x+1:x^2;s=2:x-1;u=[g(~mod(g,x)),s(~mod(x,s)&amp;s.^2&gt;=x)];u=u(~l(u));q=[q,u];l(u)=l(x)+1;end;l(b)-1

Thanks @beaker for the shortcut in in the list lengthening step!
This is a relatively straightforward dijkstra implementation:
q=a;                  %queue
l(b)=0;       %list of path lengths
l(a)=1;
while~l(b);         %if there is no predecessor to b
    x=q(1);         %get first queue element
    q=q(2:end);
    %add edges 
    l(end+1:x^2)=0;% lengthen predecessor list if too short
    g=x+1:x^2;      % g=greater neighbours
    s=2:x-1;        % s=smaller neighbours %keep only valid/unvisited neighbours 
    u=[g(~mod(g,x)),s(~mod(x,s)&amp;s.^2&gt;=x)]; %-1byte
    u=u(~l(u));
    q=[q,u];      %add only hte valid nodes edges to queue
    l(u)=l(x)+1;       %mark x as predecessor  
end;
l(b)-1 %output length to the end of the path

 no convolution today