By using network extension, the following code builds the least-cost path between two polygons (composed of several patches) :
to calculate-LCP [ID-polygon-
You only need to call nw:set-snapshot turtles links once when you first set up the network. If any weights change, or any links or nodes are added or removed, you'll need to call it again. This should speed up your code tremendously.
nw:set-snapshot turtles links