@antv/layout
graph layout algorithm
Last updated 2 years ago by panyuqi .
Original npm · Tarball · package.json
$ npm install @antv/layout 
SYNC missed versions from official npm registry.

About

Collection of basic layout algorithms to be used with @antv/graphlib.

Living Demo

Usage

NPM

Install @antv/layout first.

# npm
$ npm install @antv/layout --save

# yarn
$ yarn add @antv/layout

Choose a layout algorithm from @antv/layout then.

import { Graph } from "@antv/graphlib";
import { CircularLayout } from "@antv/layout";

const graph = new Graph({ nodes: [], edges: [] });

const circularLayout = new CircularLayout({ radius: 10 });

// 1. Return positions of nodes & edges.
const positions = circularLayout.execute(graph);

// 2. To directly assign the positions to the nodes:
circularLayout.assign(graph);

UMD

Import scripts in UMD version of @antv/graphlib and @antv/layout.

<script
  src="https://unpkg.com/@antv/graphlib"
  type="application/javascript"
></script>
<script
  src="https://unpkg.com/@antv/layout"
  type="application/javascript"
></script>

Use layouts under Layout namespace.

const { Graph } = window.GraphLib;
const { CircularLayout } = window.Layout;

Documentation

Layout algorithms can be divided into two categories, the first is synchronous, e.g. circular layout

Circular

Circular layout arranges the node on a circle. By tuning the configurations, user can adjust the node ordering method, division number, radial layout, and so on. G6 implements it according to the paper: A framework and algorithms for circular drawings of graphs.

circular layout circular layout circular layout

Arguments

  • graph Graph: target graph.
  • options? LayoutOptions.
    • center [number, number] The center of the graph. e.g. [0, 0]
    • radius number The radius of the circle. If the raidus exists, startRadius and endRadius do not take effect.
    • startRadius number The start radius of spiral layout. The default value is null.
    • endRadius number The end radius of spiral layout. The default value is null.
    • clockwise boolean Whether to layout clockwisely. The default value is true.
    • divisions number The division number of the nodes on the circle. Takes effect when endRadius - startRadius !== 0. The default value is 1.
    • ordering null | 'topology' | 'degree' The ordering method for nodes. null by default, which means the nodes are arranged in data order. 'topology' means in topology order; 'degree' means in degree order.
    • angleRatio number How many 2*PIs Between the first node and the last node. The default value is 1.

Supervisor

const graph = new Graph();
const layout = new CircularLayout();

const supervisor = new Supervisor(graph, layout, { auto: true });
supervisor.start();

License

The scripts and documentation in this project are released under the MIT License.

Current Tags

  • 1.2.13                                ...           alpha (a year ago)
  • 1.2.14-beta.9                                ...           beta (2 months ago)
  • 1.2.14-beta.8                                ...           latest (3 months ago)

161 Versions

  • 1.2.14-beta.9                                ...           2 months ago
  • 1.2.14-beta.8                                ...           3 months ago
  • 1.2.14-beta.7                                ...           4 months ago
  • 1.2.14-beta.6                                ...           4 months ago
  • 1.2.14-beta.5                                ...           5 months ago
  • 1.2.14-beta.4                                ...           7 months ago
  • 1.2.14-beta.3                                ...           8 months ago
  • 1.2.14-beta.2                                ...           8 months ago
  • 1.2.14-beta.1                                ...           9 months ago
  • 1.2.14-beta.0                                ...           9 months ago
  • 0.3.25                                ...           a year ago
  • 1.2.13                                ...           a year ago
  • 1.2.12                                ...           a year ago
  • 1.2.11-beta.0                                ...           a year ago
  • 0.3.24                                ...           a year ago
  • 1.2.11                                ...           a year ago
  • 1.2.10                                ...           a year ago
  • 1.2.9                                ...           a year ago
  • 1.2.8                                ...           a year ago
  • 1.2.7                                ...           a year ago
  • 1.2.5                                ...           a year ago
  • 0.3.23                                ...           2 years ago
  • 1.2.4                                ...           2 years ago
  • 1.2.3                                ...           2 years ago
  • 1.2.2                                ...           2 years ago
  • 1.2.1                                ...           2 years ago
  • 0.3.22                                ...           2 years ago
  • 0.3.22-beta.8                                ...           2 years ago
  • 0.3.22-beta.7                                ...           2 years ago
  • 0.3.22-beta.6                                ...           2 years ago
  • 0.3.22-beta.5                                ...           2 years ago
  • 0.3.22-beta.4                                ...           2 years ago
  • 0.3.22-beta.3                                ...           2 years ago
  • 0.3.22-beta.2                                ...           2 years ago
  • 0.3.22-beta.1                                ...           2 years ago
  • 0.3.22-beta.0                                ...           2 years ago
  • 0.3.21                                ...           2 years ago
  • 1.2.0                                ...           2 years ago
  • 1.1.0                                ...           2 years ago
  • 1.0.0                                ...           2 years ago
  • 0.3.20                                ...           2 years ago
  • 0.3.19                                ...           2 years ago
  • 1.0.0-alpha.19                                ...           2 years ago
  • 0.3.18                                ...           2 years ago
  • 1.0.0-alpha.18                                ...           2 years ago
  • 0.3.17                                ...           2 years ago
  • 0.3.17-beta.2                                ...           2 years ago
  • 0.3.17-beta.1                                ...           2 years ago
  • 0.3.17-beta.0                                ...           2 years ago
  • 1.0.0-alpha.17                                ...           2 years ago
  • 0.3.16                                ...           2 years ago
  • 0.3.15                                ...           2 years ago
  • 1.0.0-alpha.16                                ...           2 years ago
  • 0.3.15-beta.0                                ...           2 years ago
  • 0.3.14                                ...           2 years ago
  • 1.0.0-alpha.15                                ...           2 years ago
  • 1.0.0-alpha.14                                ...           2 years ago
  • 1.0.0-alpha.13                                ...           2 years ago
  • 1.0.0-alpha.12                                ...           2 years ago
  • 1.0.0-alpha.11                                ...           2 years ago
  • 1.0.0-alpha.10                                ...           2 years ago
  • 1.0.0-alpha.9                                ...           2 years ago
  • 1.0.0-alpha.8                                ...           2 years ago
  • 1.0.0-alpha.7                                ...           2 years ago
  • 1.0.0-alpha.6                                ...           2 years ago
  • 1.0.0-alpha.5                                ...           2 years ago
  • 1.0.0-alpha.4                                ...           2 years ago
  • 1.0.0-alpha.3                                ...           2 years ago
  • 1.0.0-alpha.2                                ...           2 years ago
  • 0.3.13                                ...           2 years ago
  • 1.0.0-alpha.1 [deprecated]           ...           2 years ago
  • 1.0.0-alpha.0 [deprecated]           ...           2 years ago
  • 0.3.12                                ...           2 years ago
  • 0.3.11                                ...           2 years ago
  • 0.3.10                                ...           2 years ago
  • 0.3.9                                ...           2 years ago
  • 0.3.8                                ...           2 years ago
  • 0.3.7                                ...           2 years ago
  • 0.3.6                                ...           2 years ago
  • 0.3.5                                ...           2 years ago
  • 0.3.4                                ...           2 years ago
  • 0.3.3                                ...           2 years ago
  • 0.3.2                                ...           2 years ago
  • 0.3.1                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.3.0-beta.5                                ...           2 years ago
  • 0.3.0-beta.4                                ...           2 years ago
  • 0.3.0-beta.3                                ...           2 years ago
  • 0.3.0-beta.2                                ...           2 years ago
  • 0.3.0-beta.1                                ...           2 years ago
  • 0.3.0-beta                                ...           2 years ago
  • 0.2.5                                ...           2 years ago
  • 0.2.4                                ...           3 years ago
  • 0.2.3                                ...           3 years ago
  • 0.2.2                                ...           3 years ago
  • 0.2.1                                ...           3 years ago
  • 0.2.0                                ...           3 years ago
  • 0.2.0-beta.5                                ...           3 years ago
  • 0.2.0-beta.4                                ...           3 years ago
  • 0.2.0-beta.3                                ...           3 years ago
  • 0.2.0-beta.2                                ...           3 years ago
  • 0.2.0-beta.1                                ...           3 years ago
  • 0.2.0-beta.0                                ...           3 years ago
  • 0.1.31                                ...           3 years ago
  • 0.1.30                                ...           3 years ago
  • 0.1.30-beta.1                                ...           3 years ago
  • 0.1.30-beta.0                                ...           3 years ago
  • 0.1.29                                ...           3 years ago
  • 0.1.28                                ...           3 years ago
  • 0.1.27                                ...           3 years ago
  • 0.1.26                                ...           3 years ago
  • 0.1.25                                ...           3 years ago
  • 0.1.24                                ...           3 years ago
  • 0.1.23 [deprecated]           ...           3 years ago
  • 0.1.22                                ...           3 years ago
  • 0.1.21                                ...           3 years ago
  • 0.1.20                                ...           3 years ago
  • 0.1.19                                ...           3 years ago
  • 0.1.19-beta.5                                ...           3 years ago
  • 0.1.19-beta.4                                ...           3 years ago
  • 0.1.19-beta.3                                ...           3 years ago
  • 0.1.19-beta.2                                ...           3 years ago
  • 0.1.19-beta.1                                ...           3 years ago
  • 0.1.19-beta.0                                ...           3 years ago
  • 0.1.19-beta                                ...           3 years ago
  • 0.1.18                                ...           3 years ago
  • 0.1.17                                ...           3 years ago
  • 0.1.16                                ...           3 years ago
  • 0.1.15                                ...           4 years ago
  • 0.1.14                                ...           4 years ago
  • 0.1.13                                ...           4 years ago
  • 0.1.12                                ...           4 years ago
  • 0.1.11                                ...           4 years ago
  • 0.1.10                                ...           4 years ago
  • 0.1.9                                ...           4 years ago
  • 0.1.8                                ...           4 years ago
  • 0.1.7-beta.3                                ...           4 years ago
  • 0.1.7-beta.2                                ...           4 years ago
  • 0.1.7-beta.1                                ...           4 years ago
  • 0.1.6                                ...           4 years ago
  • 0.1.5                                ...           4 years ago
  • 0.1.4                                ...           4 years ago
  • 0.1.3                                ...           4 years ago
  • 0.1.2                                ...           4 years ago
  • 0.1.1                                ...           4 years ago
  • 0.1.0                                ...           4 years ago
  • 0.0.16                                ...           4 years ago
  • 0.0.15                                ...           4 years ago
  • 0.0.14                                ...           4 years ago
  • 0.0.13                                ...           4 years ago
  • 0.0.12                                ...           4 years ago
  • 0.0.11                                ...           4 years ago
  • 0.0.10                                ...           4 years ago
  • 0.0.9                                ...           4 years ago
  • 0.0.8                                ...           4 years ago
  • 0.0.7                                ...           4 years ago
  • 0.0.6                                ...           4 years ago
  • 0.0.5                                ...           4 years ago
  • 0.0.4                                ...           4 years ago
  • 0.0.3                                ...           4 years ago
  • 0.0.2                                ...           4 years ago

© 2010 - cnpmjs.org x YWFE | Home | YWFE