In a system I Have a list of nodes which are connected like in a normal graph. We know the whole system and all of their connections and we also have a startpoint. All my edges has a direction.
Now I want to draw all of these nodes and edges automatically. The problem is not the actual drawing, but calculating the (x,y) coordinates. So basically I would like to draw this whole graph so it looks good.
My datastructure would be something like:
class node:
string text
List<edge> connections
There must be some well known algorithms for this problem? I haven't been able to find any, but I might be using the wrong keywords.
My thoughts:
One way would be to position our startnode at (0,0), and then have some constant which is "distance". Then for each neighbor, it would add distance to the y position, and for each node which is a neighbor, set x= distance*n.
But this will really give a lot of problems - so that's definetely not the way to go.