Thanks a lot @AlienRenders well i just pass the functions, i have 2 doubts, 1 is from the distance is the actual distance or the grid position? and 2, i have problems with the global connection, how to populate and where?
Here is the function to add neigh with distance and put the checkConnection.
All the stars are stored in stars(array of star)