Most of the barycenter layout tuning considerations are related to the placement of the fixed vertices. In practice the fixed vertices are always placed at the corners of a convex polygon (a polygon is convex, if it contains all the line segments connecting any pair of its points).
The positions of the fixed vertices in figure 1 are on the rim of a circle, which is a convex polygon.
You can manually perform this task or ask the layout to perform it for you. This is achieved by the following modes of the NFixedVertexPlacement class:
- Original - the layout does not change the location of the fixed vertices. The user must place the fixed vertices prior to the layout.
- PredefinedEllipseRim - in this mode the fixed vertices are placed on the rim of an ellipse the bounds of which are specified by the PredefinedEllipseBounds property.
- AutomaticEllipseRim - in this mode an automatic ellipse is generated which is large enough not to allow fixed vertex overlapping.
C# |
Copy Code
|
---|---|
// fixed vertices are placed on the rim of the specified ellipse barycenterLayout.FixedVertexPlacement.Mode = FixedVertexPlacementMode.PredefinedEllipseRim; barycenterLayout.FixedVertexPlacement.PredefinedEllipseBounds = new NRectangleF(0, 0, 700, 500); |
Visual Basic |
Copy Code
|
---|---|
' fixed vertices are placed on the rim of the specified ellipse barycenterLayout.FixedVertexPlacement.Mode = FixedVertexPlacementMode.PredefinedEllipseRim barycenterLayout.FixedVertexPlacement.PredefinedEllipseBounds = New NRectangleF(0, 0, 700, 500) |
Often the barycenter layout produces many vertex overlaps, especially in high vertex degree cases. In cases like these you may consider enabling the bounce back force:
C# |
Copy Code
|
---|---|
barycenterLayout.BounceBackForce.Enabled = true;
|
Visual Basic |
Copy Code
|
---|---|
barycenterLayout.BounceBackForce.Enabled = True
|
The following figures show the effect of this force:
figure 2. Barycenter layout without bounce back force
figure 3. Barycenter layout with bounce back force
In general the barycenter layout quickly reaches equilibrium. The best speed performance however is observed when the free vertices are placed in the fixed vertices barycenter:
C# |
Copy Code
|
---|---|
barycenterLayout.FreeVertexPlacement.Mode = FreeVertexPlacementMode.FixedBarycenter; |
Visual Basic |
Copy Code
|
---|---|
barycenterLayout.FreeVertexPlacement.Mode = FreeVertexPlacementMode.FixedBarycenter |