Class: GraphForceDirected

algo.layout. GraphForceDirected

new GraphForceDirected(dataStructure)

The force directed graph layout strategy.
Parameters:
Name Type Description
dataStructure algo.core.Graph
Source:

Classes

Point
Spring

Methods

applyCoulombsLaw()

apply the repulsive force to each vertex against each other vertex
Source:

applyHookesLaw()

apply Hookes spring law ( attractive force ) on each spring in the visualizer
Source:

attractToCentre()

all vertices/points are generally attracted to the center
Source:

eachEdge(callback)

callback for each edge in the graph. Callback is invoked with (edge, spring)
Parameters:
Name Type Description
callback
Source:

eachSpring(callback)

callback for each spring in the visualizer. Callback is invoked with (spring)
Parameters:
Name Type Description
callback
Source:

eachVertex(callback)

callback for each vertex in the graph. The callback is invoked with (vertex, point)
Parameters:
Name Type Description
callback
Source:

getBoundingBox() → {Object}

get the bounding box of the visualizer layout. This is within the visualizers internal coordinate system. Not screen or surface space
Source:
Returns:
Type
Object

getVertexPosition(vertex) → {algo.layout.Vector}

get the location within our bounds for the given vertex.
Parameters:
Name Type Description
vertex
Source:
Returns:
Type
algo.layout.Vector

point(vertex) → {algo.layout.GraphForceDirected.Point}

return a point representing a vertex, the point is added to the vertexPoints set on creation
Parameters:
Name Type Description
vertex
Source:
Returns:
Type
algo.layout.GraphForceDirected.Point

simToScreen(p)

convert the simulation point to a point within our current bounding box. Assumes that this.simBounds is up to date.
Parameters:
Name Type Description
p
Source:

spring(edge) → {algo.layout.GraphForceDirected.Spring}

create a sprint from a graph edge
Parameters:
Name Type Description
edge
Source:
Returns:
Type
algo.layout.GraphForceDirected.Spring

totalEnergy() → {number}

return the total energy in the system. This is used to short circuit the update when a near stable arrangement is obtained
Source:
Returns:
Type
number

update(box, ms)

Start the layout algorithm and run for the specified number of ms OR until the total energy in the system goes below a threshold
Parameters:
Name Type Description
box box the bounding box for the layout
ms number the maximum number of milliseconds to run the simulation for
Source:

updatePosition(timestep)

update the position of each point
Parameters:
Name Type Description
timestep
Source:

updateVelocity(timestep)

update the velocity of each vertex
Parameters:
Name Type Description
timestep
Source: