If you simply want to avoid your lines from crossing, then Christian Graus's solution would work fine. However I think this solution will limit you to very simple layout diagrams. If you would like your tool to be able to layout complex paths, I would suggest looking up path-finding on Google. I have seen many sample applications, you may be able to find one that will work for you. Good Luck
Build a man a fire, and he will be warm for a day
Light a man on fire, and he will be warm for the rest of his life!