ForceSimulation class

Force simulation for laying out network graphs.

Constructors

ForceSimulation({required List<NetworkNode> nodes, required List<NetworkLink> links, double alpha = 1.0, double alphaMin = 0.001, double alphaDecay = 0.0228, double alphaTarget = 0, double velocityDecay = 0.4, List<Force>? forces, void onTick()?, void onEnd()?})
ForceSimulation.withDefaults({required List<NetworkNode> nodes, required List<NetworkLink> links, double centerX = 0, double centerY = 0, double chargeStrength = -30, double linkDistance = 30, void onTick()?, void onEnd()?})
Creates a simulation with default forces.
factory

Properties

alpha ↔ double
Simulation alpha (temperature).
getter/setter pair
alphaDecay ↔ double
Alpha decay rate per tick.
getter/setter pair
alphaMin ↔ double
Minimum alpha before simulation stops.
getter/setter pair
alphaTarget ↔ double
Target alpha for reheating.
getter/setter pair
forces → List<Force>
Forces applied to the simulation.
final
hashCode → int
The hash code for this object.
no setterinherited
isRunning → bool
Whether the simulation is currently running.
no setter
Links in the simulation.
final
nodes → List<NetworkNode>
Nodes in the simulation.
final
onEnd ↔ void Function()?
Callback when simulation ends.
getter/setter pair
onTick ↔ void Function()?
Callback when simulation ticks.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
velocityDecay ↔ double
Velocity decay (friction).
getter/setter pair

Methods

addForce(Force force) → void
Adds a force to the simulation.
findNode(double x, double y, {double radius = double.infinity}) → NetworkNode?
Finds the node closest to a point.
getNode(String id) → NetworkNode?
Gets a node by ID.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
removeForce(Force force) → void
Removes a force from the simulation.
restart() → void
Reheats the simulation.
start() → void
Starts the simulation.
stop() → void
Stops the simulation.
tick() → void
Runs a single tick of the simulation.
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited