ForceLayout<V> class
final
Positions vertices using a physical simulation of spring attraction and electrical repulsion.
Supports exact $O(V^2)$ simulation or Barnes-Hut $O(V \log V)$ approximation for large graphs via RepulsionMode.barnesHut.
final graph = Graph<String, void>.undirected()
..addEdge('A', 'B')
..addEdge('B', 'C');
final result = graph.layout(const ForceLayout(seed: 42));
print(result.positions['A']);
- Inheritance
-
- Object
- GraphLayout<
V> - ForceLayout
Constructors
-
ForceLayout({ForceConfig config = const ForceConfig(), LayoutRectangle bounds = const LayoutRectangle(0, 0, 800, 600), Set<
V> ? pinned, Map<V, LayoutPoint> ? initialPositions, int? seed, Random? random, double vertexDistance = 20.0}) -
Constructs a force-directed layout strategy.
const
Properties
- bounds → LayoutRectangle
-
Bounding area guiding the simulation scale and gravity center.
final
- config → ForceConfig
-
Simulation parameters governing forces, cooling, and repulsion mode.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
-
initialPositions
→ Map<
V, LayoutPoint> ? -
Optional initial positions for vertices.
final
- packDisconnectedComponents → bool
-
Whether this layout strategy decomposes disconnected components and packs them.
no setterinherited
-
pinned
→ Set<
V> ? -
Optional set of vertices whose positions remain fixed during simulation.
final
- random → Random?
-
Optional explicit random number generator.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- seed → int?
-
Optional pseudo-random seed for deterministic simulation.
final
- vertexDistance → double
-
Spacing factor between vertices.
final
Methods
-
layout(
LayoutInput< V> input) → LayoutResult<V> -
Computes vertex positions and optional edge routes for
input.inherited -
layoutComponent(
LayoutInput< V> input) → LayoutResult<V> - Internal layout implementation for a single connected component.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited