Usage guidesLayoutRecommended optional layouts

MDS layout

Multidimensional scaling (MDS) approximates shortest-path distances in two dimensions.

Overview

Multidimensional scaling (MDS) approximates shortest-path distances in two dimensions.

When to use it

Use it to examine how close or far apart nodes are in a network.

Basic usage

This layout is optional. Import and register it before setting layout.type. For CDN usage, see Optional layouts.

import { Graph, register } from '@antv/g6-lite';
import mds from '@antv/g6-lite/layouts/mds';

register('layout', 'mds', mds);

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

Options

OptionDescriptionTypeDefault
linkDistanceReference length used to scale graph distances.number50
centerCenter of the layout in graph coordinates.[number, number]Center of the layout area

Common layout options · Layout reference

Code example

The example uses a scale of 80. Nodes farther apart in the network generally appear farther apart on the canvas.

Loading example…
Drag to pan or scroll to zoom.
import { register } from '@antv/g6-lite';

import mds from '@antv/g6-lite/layouts/mds';

register('layout', 'mds', mds);

const layout = { type: 'mds', linkDistance: 80 };

Compare network layouts