Wandering Cube - Grasshopper Script

I want to create a script that when given two inputs from an array of cubes, the script connects the two. See attached. Preferably this script would “wander” around the other cubes, not necessarily finding the quickest route.