C# 
Copy Code


// create a new force directed layout associated with the specified document NForceDirectedLayout fdLayout = new NForceDirectedLayout(document); 
Visual Basic 
Copy Code


' create a new force directed layout associated with the specified document Dim fdLayout As New NForceDirectedLayout(document) 
Force directed layouts view the graph as a system of bodies with forces acting between the bodies. The algorithm seeks a configuration of the bodies with locally minimum energy, that is a position for each body, such that the sum of the forces on each body is zero. Such configuration is called equilibrium configuration. Generally all force directed layouts are defined by two parts:
The current implementation of NForceDirectedLayout is based on a model with spring and electrical forces acting upon the graph vertices. In this model edges between graph vertices represent springs connecting the vertices. Vertices are treated as equally charged particles, which repel each other. The force acting on each vertex v is:
where:
An iterative algorithm is implemented, which tries to reach an equilibrium configuration in a finite number of iterations  controlled by the MaxIterations property.
You can choose whether the algorithm must randomize the vertex positions prior to its execution with the help of the RandomizePositions property.
On each iteration the algorithm computes the force acting on each vertex and each vertex is moved in the direction of that force by a small amount of it's force magnitude, controlled by the ForceMagnitudeFactor property.
The algorithm stops if it has performed the maximum number of iterations or all forces in the system are smaller than the value specified by the StopForce property  that is the system has reached an equilibrium approximation.
Common layout features  NForceDirectedLayout