ForceAtlas2.js 718 Bytes
Newer Older
1 2 3 4
'use strict';

// https://graphology.github.io/standard-library/layout-forceatlas2.html

5
// import forceAtlas2 from 'graphology-layout-forceatlas2';
6 7
import FA2Layout from 'graphology-layout-forceatlas2/worker';

8 9
export function _init(graph, settings) {
  // let inferred = forceAtlas2.inferSettings(graph);
10
  // console.log('[init] graph', graph, 'settings', settings);
11
  return new FA2Layout(graph, {
12
    settings,
13
    iterations: 1,
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
    getEdgeWeight: 'weight'
  })
}

export function _start(layout) {
  return layout.start();
}

export function _stop(layout) {
  return layout.stop();
}

export function _kill(layout) {
  return layout.kill();
}

export function _isRunning(layout) {
  return layout.isRunning();
}