Class ForceDirectedLayout

Force-directed layout treats the graph as if it were a system of physical bodies with forces acting on them and between them. The algorithm seeks a configuration of the bodies with locally minimal energy, i.e. vertex positions such that the sum of the forces on each vertex is zero.

Hierarchy

Index

Constructor methods

Properties

Methods

Constructor methods

constructor(): ForceDirectedLayout

Constructs a ForceDirectedLayout with no Layout#network and with no owning Layout#diagram.

Returns

ForceDirectedLayout

Properties

public arrangementOrigin: Point

Gets or sets the top-left point for where the graph should be positioned when laid out.

public arrangementSpacing: Size

Gets or sets the space between which the layout will position the connected graphs that together compose the network.

public arrangesToOrigin: boolean

Gets or sets whether #commitNodes should move all of the nodes so that the nodes all fit with the top-left corner at the Layout#arrangementOrigin.

public comments: boolean

Gets or sets whether this layout should find all Nodes whose category is "Comment" and whose anchors are nodes represented in the network, and add ForceDirectedVertexes representing those balloon comments as nodes in the network.

public currentIteration: number

Gets the current iteration count, valid during a call to #doLayout.

public defaultCommentElectricalCharge: number

Gets or sets the default value computed by #electricalCharge.

public defaultCommentSpringLength: number

Gets or sets the default value computed by #springLength.

public defaultElectricalCharge: number

Gets or sets the default value computed by #electricalCharge.

public defaultGravitationalMass: number

Gets or sets the default value computed by #gravitationalMass.

public defaultSpringLength: number

Gets or sets the default value computed by #springLength.

public defaultSpringStiffness: number

Gets or sets the default value computed by #springStiffness.

public diagram: Diagram

Gets the Diagram that owns this layout, if it is the value of Diagram#layout.

public epsilonDistance: number

Gets or sets approximately how far a node must move in order for the iterations to continue.

public group: Group

Gets the Group that uses this layout, if it is the value of a group's Group#layout.

public infinityDistance: number

Gets or sets a threshold for the distance beyond which the electrical charge forces may be ignored.

public isInitial: boolean

Gets or sets whether this layout is performed on an initial layout.

public isOngoing: boolean

Gets or sets whether this layout can be invalidated by #invalidateLayout.

public isRealtime: boolean

Gets or sets whether this layout be performed in real-time, before the end of a transaction.

public isRouting: boolean

Gets or sets whether this layout routes Links.

public isValidLayout: boolean

Gets or sets whether this layout needs to be performed again.

public isViewportSized: boolean

Gets or sets whether this layout depends on the Diagram#viewportBounds's size.

public maxIterations: number

Gets or sets the maximum number of iterations to perform when doing the force-directed auto layout.

public newtork: LayoutNetwork

Gets or sets the LayoutNetwork used by this Layout, if any.

public setsPortSpots: boolean

Gets or sets whether the fromSpot and the toSpot of every Link should be set to Spot#Default.

Methods

public commitLayout(): any

Position the Nodes according to the Vertex positions.

Returns

any

public commitLinks(): any

Commit the position and routing of all edge links.

Returns

any

public commitNodes(): any

Commit the position of all vertex nodes.

Returns

any

public copy(): Layout

Creates a copy of this Layout and returns it.

Returns

Layout

public createNetwork(): LayoutNetwork

Create a new LayoutNetwork of ForceDirectedVertexes and ForceDirectedEdges.

Returns

LayoutNetwork

public doLayout(coll: Diagram): any

Assign the positions of the vertexes in the network.

Parameters

  • coll: Diagram

    A Diagram or a Group or a collection of Parts.

Returns

any

public doLayout(coll: Group): any

Parameters

Returns

any

public doLayout(coll: Iterable): any

Parameters

Returns

any

public electricalCharge(v: ForceDirectedVertex): number

Returns the charge of the vertex, the value of ForceDirectedVertex#charge if it's a number, or else the value of #defaultElectricalCharge.

Parameters

Returns

number

public electricalFieldX(x: number, y: number): number

Returns the electrical field in the X direction acting on a vertex at the given point.

Used to define an external electrical field at a point independent of the vertex charges. A vertex L is acted upon by a force in the X direction of magnitude

Parameters

  • x: number
  • y: number

Returns

number

public electricalFieldY(x: number, y: number): number

Returns the electrical field in the Y direction acting on a vertex at the given point.

Used to define an external electrical field at a point independent of the vertex charges. A vertex L is acted upon by a force in the Y direction of magnitude

Parameters

  • x: number
  • y: number

Returns

number

public gravitationalFieldX(x: number, y: number): number

This returns the gravitational field in the X direction acting on a vertex at the given point.

Used to define an external gravitational field at a point independent of the vertex masses. A vertex L is acted upon by a force in the X direction of magnitude

Parameters

  • x: number
  • y: number

Returns

number

public gravitationalFieldY(x: number, y: number): number

This returns the gravitational field in the Y direction acting on a vertex at the given point.

Used to define an external gravitational field at a point independent of the vertex masses. A vertex L is acted upon by a force in the Y direction of magnitude

Parameters

  • x: number
  • y: number

Returns

number

public gravitationalMass(v: ForceDirectedVertex): number

Returns the mass of the vertex, the value of ForceDirectedVertex#mass if it's a number, or else the value of #defaultGravitationalMass.

Parameters

Returns

number

public invalidateLayout(): any

If #isOngoing is true and if an initial layout has not yet been performed, set the #isValidLayout property to false, and ask to perform another layout in the near future.

Returns

any

public isFixed(v: ForceDirectedVertex): boolean

This predicate returns true if the vertex should not be moved by the layout algorithm but still have an effect on nearby and connected vertexes. The default implementation returns ForceDirectedVertex#isFixed.

Parameters

Returns

boolean

public makeNetwork(coll: Diagram): LayoutNetwork

Create and initialize a LayoutNetwork with the given nodes and links.

Parameters

  • coll: Diagram

    A Diagram or a Group or a collection of Parts.

Returns

LayoutNetwork

public makeNetwork(coll: Group): LayoutNetwork

Parameters

Returns

LayoutNetwork

public makeNetwork(coll: Iterable): LayoutNetwork

Parameters

Returns

LayoutNetwork

public springLength(e: ForceDirectedEdge): number

Returns the length of the spring representing an edge. The two vertexes connected by the edge E are acted upon by a force of magnitude

Parameters

Returns

number

public springStiffness(e: ForceDirectedEdge): number

Returns the stiffness of the spring representing an edge. The two vertexes connected by the edge E are acted upon by a force of magnitude

Parameters

Returns

number

public updateParts(): any

When using a LayoutNetwork, update the "physical" node positionings and link routings.

Returns

any