documentationfor yFiles for HTML 3.0.0.2

GenericLabeling

A generic labeling algorithm for placing the labels of a graph.

Inheritance Hierarchy
LayoutStageBase
GenericLabeling
Implemented Interfaces

Remarks

Node labels and edge labels placed by the labeling algorithm

This algorithm places the labels of a graph without moving its nodes or edges. It can switch between two internal implementations. By default, it generates high quality label placements even for difficult instances. This especially holds true if the label models allow a large number of different LabelCandidates, i.e., there is a high potential for optimizations.

If the duration of the calculation is of utmost importance, the internal algorithm can be changed to a simpler implementation by setting stopDuration to ZERO. On the downside, the results will not be as good as those of the default mode.

In default mode, this algorithm reduces the labeling problem to the maximum independent set (MIS) problem and solves the problem using simulated annealing. It is inspired by the article from Christensen, Marks and Shieber: A General Cartographic Labeling Algorithm.

Concept

Generic labeling algorithms use the label candidate factory associated with a label (see nodeLabelCandidates for node labels and edgeLabelCandidates for edge labels). The factories are necessary to compute a set of LabelCandidates, i.e., candidate positions for a label. Then, one best matching candidate from the set will be selected by the algorithm. This selection depends on several preferences, e.g., the custom weights given by weight, the specified edgeLabelCandidateProcessors, as well as the associated EdgeLabelPreferredPlacement (for edge labels).

For high quality results, it is recommended to use free edge label candidates and free node label candidates which allow free positioning of labels. Note that this usually induces a higher runtime compared to using a more restricted candidate factory (e.g. addDiscreteCandidates).

Features

By combining this stage with a coreLayout, the labeling will take place after the core layout was executed (applyLayoutImpl). This is especially useful if the core layout does not support label handling.

Performance

Specifying a stopDuration can reduce the time the GenericLabeling algorithm takes to produce a result. The acceleration is achieved by loosening the requirements for terminating the incremental improvement of the label positions. It should be noted that the stopDuration is not a guarantee for the maximum time spent, as the algorithm still has to produce a valid result.

The qualityTimeRatio can be used to specify a preference for the balance between the quality of the calculated result and the time spent on calculating it.

Default Values of Properties

defaultEdgeLabelingCostsBALANCEDThe different types of preferences for the placement of the edge labels are balanced.
defaultNodeLabelingCostsBALANCEDThe different types of preferences for the placement of the node labels are balanced.
deterministictrueLabeling results are deterministic.
qualityTimeRatio1.0
scopeALLAll labels are affected.
stopDurationMAX_VALUEThere is no time limit.

Type Details

yFiles module
algorithms

See Also

Constructors

Properties

Methods

Constants