How to detect two objects attached while using python scripting?

Dear all, trying to move objects in scene by scripting, in this case, i would like to move object A to object B as close as possible(but i dont want them attached), is there any api or method to check whether this movement connect two object. btw, two objects connected means they share at least one vertex, thus in math, they share a same vector, am i right?