Hello,
I need to do the following. I have some nodes, which i display into a graph (using x,y coordinates). Nodes have specific width. Nodes, are connected to each other using straight lines, so it is like i.e. putting rectangles into a 2d space, while these boxes are connected to each other with lines. I am looking for an algorithm which i should implement, that would find the best possition {x,y} for the boxes so that:
1. Boxes are alligned, i mean if BoxA,Box B are put one next to another, y to be exactly the same...
2. Boxes connected to each other are as close as possible.
3. Lines connecting boxes do not pass above boxes
4. Where possible, lines are not crossing each other.
These rules are on the top of my head.. The general idea is that i wish this graph of nodes/lines, to be presented in a relativelly nice way to user... My current implementation is putting these nodes, randomly and the result is not nice. Anyone can point me to the correct direction to search. Even if this is a keyword in google that will put me in the right track would be helpfull because anything i found up to now was not much of a help.
Re: organizing nodes connected with lines in 2d space
It seems you have the overall strategy pretty clear. It's the steps 1 to 4 you describe.
So why don't you start implementing it. Then if you run into trouble with something of a more algorithmic nature you come back.
That's because agorithms can never help you with "presented in a relatively nice way to the user". That falls within the realms of human perception.
My advice is to keep it simple. If you end up with a layout that requires extremely expensive algorithms you're most likely on the wrong track. I've often falling into the trap of trying far too complex approaches when in the end the simplest turned out the best.
On the other hand I think this problem is quite common so there should be plenty of examples abound. Maybe you could even buy an off the shelf solution and incorporate it into your application. There must be commercial alternatives for sure. It's seldom said in an algorithms forum but buying is often the best option by far.
Last edited by nuzzle; July 13th, 2012 at 06:48 PM.
Bookmarks