How to validate the connections between elements dragged and dropped?

How to check if an element is connected to some other element ? There should at-least one incoming or one outgoing or both.