Let me try to understand your problem, because it's not immediately clear from the pictures. You have a finite set of points (the red dots), you are currently at one of them and you want to design a path through all the other nodes, minimizing total distance travelled. Is that it? If so, ask Google about the "travelling salesman problem": The original problem includes returning to the starting point at the end of the path, but you can probably use pretty much the same algorithms in your case.

If that is not your problem, please try to state it as clearly as possible.