Node<T> class

A class representing a node in a graph, holding a reference to arbitrary data of type T.

It also holds information needed to play its role in the context of a force directed graph, like position in the 2D space as a Vector2, the mass as a double.

Internally if also holds the _force acting on the Node, the current _velocity and whether the Node is fixed in place.

Node instances are referenced by Edge instances to implement the concept of a graph.

Furthermore Node instances are referenced by KDNode instances to allow their information to be used in the KDTree implementation.

Constructors

Node(T data, [Vector2? position])
Construct a Node instance from a given data of type T.

Properties

data → T
final
hashCode int
The hash code for this object.
no setteroverride
mass double
getter/setter pair
position ↔ Vector2
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

applyForce(Vector2 force) → void
Adds a force to the current force acting on the Node.
calculateRepulsionForce(Node other, {required double k}) → Vector2
Calculate the repulsive force following Coulomb's law.
connect(Node other) Edge
Connects the current Node with the other Node by creating (and returning) an Edge
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
static() → void
toString() String
Returns a string representation of the Node instance, including the data, the position, the _force and the _velocity.
override
unStatic() → void
updatePosition({required double scaling, required double minVelocity, required double maxStaticFriction, required double damping}) bool
Calculates the displacement within a time step and by that the new position of the Node based on mechanics using the given parameters.

Operators

operator ==(Object other) bool
Implements equality based on if the other is a Node and the data is equal.
override