It seems that the main improvement that you are missing is turning your chart into a multi-level chart. This is not an easy task, but it is doable . (The quality of the result may vary depending on the amount of time and thought invested in the process).
The main idea is to do some sort of topological sorting on the graph, to break it into layers, perform some measures in it, and then draw the graph. (you can find python code to create a real topological sort on the Internet ( example ), but the real TS just creates a long line graph and we want something a little different)
So, I will try to describe the algorithm for converting a given graph to a multilevel graph:
Topological sorting does not work on graphs with loops, so if the input graph is no longer a directed graph without loops, you will need to find a set of edges that you can delete (or possibly cancel) to create a loop graph (you will add them to multi-level schedule, but this will slow down the stratification and make the schedule less attractive :). Since finding the smallest possible set of edges that you can remove is NP-complete (very difficult) - I think you will need to make a few shortcuts here and not necessarily find the minimum set of edges, but do it in a reasonable amount of time.
Brake the chart into layers, there are many optimizations that can be done here, but I suggest you make it simple. iterate over all vertices of the graph and each time collect all the vertices without incoming edges on the layer. This can lead to line graphing in some simple cases, but it is well suited for UML graphs.
A good graph is one that has the least number of edges intersecting each other . This does not really matter, but this fact contributes greatly to the overall look of the chart. what determines the number of intersections is the order of the edges in each layer. But again, searching for the minimum number of intersections or searching for the maximum crossing set of edges NP-complete: ("so again this is typical for resorting to heuristics, for example, placing each vertex in a position determined by finding the average or median position of its neighbors at the previous level and then replace adjacent pairs if that improves the number of transitions. "
The edges deleted (or reversed) in the first step of the algorithm are returned to their original position.
And here it is! A nice layered graph for your UML.
- If my explanations were not clear enough, try reading the Wikipedia article on Multilevel Graphic Drawing again or ask me any questions, and I will try to answer.
- Remember that this is an algorithm for the general case, and parties can be optimized to better cope with a specific case.
- If you want more ideas for the features of your UML tool, take a look at the wonderful work Jetbrains does for its IntelliJ UML tool.
Hope my comments here are helpful.
Important update: since you stated that you are "Look for a response drawing from reliable and / or official sources." I am attaching This is the Formal documentation from graphviz (the point algorithm), which "describes a four-pass algorithm for drawing oriented graphs. The first pass receives optimal rank assignment using the simplex network algorithm. The second pass establishes the order of vertices in the ranks using iterative heuristics including a new weight function and local transpositions to reduce intersections. The third pass determines the optimal coordinates for nodes by constructing and ranking the auxiliary graph ka. The fourth pass makes splines for drawing edges. The algorithm makes good drawings and works fast. " http://www.graphviz.org/Documentation/TSE93.pdf
source share