I have a (cyclic undirected) graph stored in a suitable structure (which depends on the language chosen). Nodes represent places in the real world and edges represent connection between them, so I have a sort of initial guess of the drawing.
I have to draw this graph with some constraints and requirements, and from what I have read (scientific literature and books on graph drawing), currently none of the algorithm specifically addresses that requirements, although Sugiyama's magnetized springs are quite close to what I want to achieve. Simulated Annealing, however, could solve that problem, if a suitable cost function is provided, which is not a simple task.
So the question is: could you help me make a program which solve graph drawing problem with the constraints enumerated below?
Constraints and requirements
- Edges must be aligned at 45 k degrees, with k between 0 and 7 (or at least integer if this requirement is too strong). However, during the execution of the algorithm, I think there's no reason to prohibite violation of that constraint.
- Since the graph represent physical places, the algorithm must keep relative positions (e.g. if node A is north-north east of B in the initial guess, A must be north or north east of B, but exceptions can be made to meet the next requirement).
- Node distance should tend to a "natural" predefined length and alignment (if the graph is an open chain, the algorithm should output equally spaced nodes aligned on a line)
- Bends should take place at nodes and the angle between two adjacent edges should be 135 degrees, except for forks.
- Edge crossings must be avoided.
- Labels must not overlap any part of the drawing and should be positioned by the following specs (0 degree = horizontal axis, counterclockwise rotation of the text box):
- Orthogonal to the super-edge (aggregation of aligned edges) if this one is not horizontal
- Bend: prefer [convex side, orthogonal to the longest adjacent super-edge]
- Horizontal edge
- 45 degrees
- -45 degrees
- -135 degrees
- Horizontal below
- Horizontal above
- 135 degrees
I have not chosen the programming language yet, but I think I'll stick to C/C++, Python, Perl or Lua. The input will be the "object" I talked about in the beginning, and the output will be the same "object" with node positions changed by the optimization algorithm.
Typical problems will have about 500 nodes, with small areas densely populated and connected and less dense (but not unique) connections between these areas. I'm not interested in efficiency, at least for the moment.