Usage guidesLayout

Force layout

Attraction pulls linked nodes together and repulsion keeps nodes apart.

Overview

Attraction pulls linked nodes together and repulsion keeps nodes apart.

When to use it

Use it to explore connections in social or service dependency networks.

Basic usage

Set the layout type with layout.type.

const graph = new Graph({
  container,
  data,
  layout: { type: 'force' },
});

Options

OptionDescriptionTypeDefault
linkDistanceTarget distance between linked nodes.number200
nodeStrengthRepulsion strength between nodes.number1000
edgeStrengthAttraction strength along an edge.number50
maxIterationMaximum number of iterations.numberDepends on node count

Common layout options · Layout reference

Code example

The example sets the target distance between connected nodes to 100.

Loading example…
Drag to pan or scroll to zoom.
const layout = { type: 'force', linkDistance: 100 };

Compare network layouts