In the field of data visualization, it is often necessary to distribute the data according to certain rules, so that the data display is intuitive, clear and at a glance. In the engineering practice, I encountered a problem: how to make a multi-relationship with the point-edge graph according to the tree layout?
On the basis of consulting a large number of domestic and foreign materials, the author found a paper written by Bill Mill: drawing presentable trees.
Here is a brief description of the approximate idea of the algorithm: The algorithm uses a depth-first approach to traverse the entire multi-fork tree. The first step: if it is a leaf node, its x-coordinate equals the x-coordinate of its left sibling plus the spacing distance, if the non-leaf node, its x-coordinate equals the x-coordinate of its left sibling plus the spacing distance, simultaneously recording the offset (the difference between the x-coordinate and the midpoint of the child node). Step Two: Move all child nodes at the parent node's offset. The third step: calculate the contour of the multi-fork tree, if the contour value is less than 0 indicates that there is overlap between the left and right sub-tree, and offset that contour value.
Tree layout of layout algorithms