Enum ArrangeAlgorithmType
- Namespace
- GeometryHelper.Arranging
- Assembly
- GeometryHelper.dll
Label arrangement algorithm strategies.
public enum ArrangeAlgorithmType
Fields
Greedy = 0Greedy algorithm:
- How it works: Sorts labels by priority (freedom degree or geometry), then sequentially places each label at its best candidate position. Already placed labels become static obstacles for subsequent labels.
- Advantages: Extremely fast, low computational complexity, stable and deterministic results.
- Disadvantages: Easily falls into local optima; earlier placed labels take up good spots, causing later labels to be stuck in collisions.
BoundedBacktracking = 1Bounded Backtracking algorithm:
- How it works: Places labels sequentially, but when the k-th label encounters a collision, the algorithm backtracks to the (k-1)-th label to try its next candidate position, making room. MaxBacktrackSteps is enforced to prevent thread hangs.
- Advantages: Effectively overcomes the local optima of Greedy, increasing the success rate of collision-free arrangements.
- Disadvantages: Slower than Greedy when dealing with extremely dense drawings requiring many backtrack attempts.
SimulatedAnnealing = 2Simulated Annealing algorithm:
- How it works: Places all labels at their default positions. Runs random optimization based on simulated temperature cooling. In each cycle, randomly changes the position of a label and accepts the change based on global collision reduction (or Boltzmann probability if energy worsens).
- Advantages: Excellent ability to find global optimal solutions even in heavily congested drawings with severe collisions.
- Disadvantages: Non-deterministic results between different runs and consumes more CPU.
ForceDirected = 3Force-directed (Spring embedder) algorithm:
- How it works: Simulates a continuous physical system where labels repel each other (Coulomb force) and springs pull them back to their origin. After running simulation steps, performs Discrete Mapping of continuous label centers to the nearest non-colliding discrete candidate positions.
- Advantages: Labels are distributed very naturally, evenly, and visually dynamically.
- Disadvantages: Continuous physical force calculation is complex; sometimes labels can be pushed excessively if repulsion forces are too extreme.
ConstraintSatisfaction = 4Constraint Satisfaction Problem (CSP) algorithm:
- How it works: Treats each label as a variable and discrete candidates as the domain. Runs the constraint satisfaction algorithm using MRV Heuristic (Minimum Remaining Values - variables with fewer choices are assigned first) combined with Forward Checking (prunes conflicting candidates in neighboring variables early).
- Advantages: Solves the problem with extremely rigorous mathematical logic, optimizing constraints to avoid overlap completely.
- Disadvantages: High algorithmic complexity; large number of labels can cause combinatorial explosion if domain size is too wide and deep.