documentationfor yFiles for HTML 3.0.0.2

LayoutAbortController

Controls the early termination of graph algorithms.

Inheritance Hierarchy
LayoutAbortController

Remarks

The LayoutAbortController class allows graph algorithms to be interrupted or terminated before they complete. It supports both graceful terminations (via the stop method) and immediate cancellations (via the cancel method).

This class is particularly useful when algorithms are long-running and need to be interrupted due to time constraints or user interactions. It can be used in both multithreaded and single-threaded scenarios.

Usage in Client Code

When working with IGraph and related APIs, the LayoutAbortController of the LayoutExecutor provides an instance of this class that can be configured and monitored by layout algorithms.

If working directly with the LayoutGraph API, an instance of this class should be attached via the layoutAbortController property. This ensures that layout algorithms executed on the graph will respect stop or cancel requests.

  • stop – Schedules a request for graceful termination. This allows the algorithm to finish its current step and leave the graph in a consistent state.
  • cancel – Requests an immediate termination, discarding any partial results. There is no guarantee that the graph or the layout algorithm will be left in a consistent state, and any in-progress work will be discarded.

In scenarios where an algorithm runs multiple times on the same graph or where different algorithms are applied sequentially, the controller must be reset using the reset method before each execution. Failure to reset the controller can result in unintended early terminations due to lingering stop or cancel requests.

stop and cancel are designed for multithreaded scenarios where the algorithm runs in a background thread while the stop or cancel requests are issued from the main thread. In single-threaded environments, you can use stopDuration and cancelDuration to automatically terminate an algorithm after a specified duration.

Algorithm Development

When developing custom algorithms, you should query the controller for termination requests by invoking the check method at appropriate points within the algorithm. This ensures that stop and cancel requests are respected, allowing for smooth integration with the LayoutAbortController.

If a stop request is detected, ensure the algorithm completes its work in a way that keeps the graph in a consistent state. If a cancel request is detected, terminate immediately and discard any intermediate results.

Default Values of Properties

cancelDurationMAX_VALUENo automatic termination will occur.
stopDurationMAX_VALUENo automatic termination will occur.

Type Details

yFiles module
algorithms

See Also

Constructors

Properties

Methods