Link handling with ForceDirectedLayout

Hi,

We are using a ForceDirectedLayout for our diagrams, which mostly give us the results that we want.
However, there are a couple of points that could be improved from our point of view. We’re not quite sure how to address them and we’d appreciate any advice.

Here is the diagram we get right after applying the ForceDirectedLayout:

And here is the diagram we’d actually want, which we get through pretty simple manual tweaks:

Now to explicitly list the points we’d like to improve:

  1. Prevent needless link crossing. In the second diagram, we moved the “Objective Save Money” node to prevent the “motivates” and “delivers” links from crossing each other. Would it be possible to have the layout automatically place nodes so as to minimize such link crossing?

  2. Straighten links. In the second diagram, we aligned some of the nodes so that the links between them are more at a right angle. For example, the “Main Business Unit” node was shifted slightly to the left so that it aligns with the “Business Planning” node and their “delivers” link is straightened. Once again, would it be possible to get this result automatically from a ForceDirectedLayout?

Thanks in advance for any pointers regarding this.

Sorry, but the simple answer is that ForceDirectedLayout does not provide that functionality automatically.

  1. I bet if you load the same graph several times, there will be times when that graph would be laid out without any link crossings. That’s just the nature of the layout combined with the random forces exerted on nodes that occupy exactly the same location. I suppose a custom layout could run the layout several times and choose the results with the least number of crossings.

  2. You might want to align some nodes programmatically as part of the layout. But it isn’t clear to me exactly which ones should line up. Maybe you want to line up those connecting with a special node, such as the dotted red node in your screenshot? Such knowledge is clearly very application-dependent, which is why the standard ForceDirectedLayout cannot do that automatically.