Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a complex non-binary graph model.
Each tree node can have multiple children&parents (a node can also have a connection to it's "brother").

A node is represented as square on screen with lines to the connected nodes.
For that I want to use Draw2D and GEF libraries.

The problem I am facing is the graph layout.

I need a nice algorithm that can reposition the square nodes and the connections with minimum intersections and also make it symmetric as possible.

share|improve this question
If a node has multiple parents, it is not a tree. – ftr Mar 16 '12 at 13:38
Have you looked into GraphViz? – FrustratedWithFormsDesigner Mar 16 '12 at 13:39
@ftr yes, it's graph. – mariki Mar 16 '12 at 13:47
JUNG is a graph visualization framework for Java, but I don't know how well it fits into your technology stack. – ftr Mar 16 '12 at 13:52
If there are parents, children and siblings, must the siblings be aligned along an axis? Are there any restrictions at all visually? Aside from minimum intersections? Is distance between connections a factor? – AlexMA Apr 18 '12 at 2:42

Your parent-child relation probably creates a partial order. Google "partial order graph layout" and top hits mention things like "Coffman–Graham algorithm" and "Hasse diagrams." Maybe some research in those directions would be productive.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.