Label Placement and Node Sizing
This page documents how KLay Layered implements label placement and node sizing.
Contents
Relationship Between Label Placement and Node Size
At first glance, label placement and node sizing are two separate problems. However, out of the three types of labels we currently support – node labels, port labels, and edge labels – two have considerable influence on the size of nodes (node labels and port labels, but you already figured this out yourself). Well, in fact, that's not completely true. It's not the labels that influence the size of nodes, it's the placement of labels. And if we didn't care for readability, the placement wouldn't influence node size at all. But we do. Take this simple example:
The two nodes have to labeled ports each. Let's assume port positions to be fixed, and labels to be placed inside the nodes. Clearly, the left node is too narrow for the port labels to be placed without overlaps. If the labels are to be placed without overlaps, we need to increase the width of the node. Label placement influences node sizing.
Just how much and in what ways the two influence each other is one source of complexity. One important task in implementing label placement and node sizing is to determine the cases where we simply give up. If the user gives us fixed node sizes and fixed port positions, he cannot expect us to find an overlap-free placement if port labels are to be placed inside the node.