Click here to Skip to main content
15,902,198 members
Please Sign up or sign in to vote.
4.00/5 (2 votes)
See more:
I am looking for a way to draw a connector between two boxes that will draw the shortest non colliding path between two boxes without colliding with other boxes

say I want to draw a path from point 25,10 on the form and point 200,225

and this line shoudl avoid any and all boxes between them
also the rule is that the line can ony incremennt/decrememnet on the x or y axis not both (as to say no vetors)

can anyone give me a quick easy algorithm to do this ?
Sandeep Mewara 9-Jan-13 4:01am    
What have you tried so far? Any effort?

1 solution

Hello Chona1171,

A most common solution algorithm for your problem is to use the Dijkstra's Algorithm.

Click to read about Dijkstra's Algorithm

There's this nice article in CodeProject:
C# - Visualizing Path Finding With Dijkstra, AStar, Bi-directional Dijkstra's, and Bi-directional A* Algorithms[^]
Share this answer
Espen Harlinn 10-Jan-13 9:56am    
Nice reply :-D
Herbisaurus 18-Aug-13 2:39am    
Nice answer!
Jibesh 10-Jan-13 19:07pm    
True. 5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900