cytoscape-arbor
Description
The Arbor physics simulation layout for Cytoscape.js
The arbor
layout gives relatively slow and poor results compared to other physics simulation layouts. Consider using cose
, cose-bilkent
, or cola
instead.
The arbor
layout uses a force-directed physics simulation. For more information about Arbor and its parameters, refer to its documentation.
Notes about Arbor:
- For webworkers to work properly, you need to point your browser to a server URL (e.g.
http://
) rather than a local address (e.g. file://
). - Please note that the
liveUpdate
option can potentially be expensive, so if you are concerned about running time (e.g. for large graphs), you should set it to false
. - Arbor does some automatic path finding because it uses web workers, meaning you have to directly include it in a
<script>
in your <head>
. Therefore, you can not combine arbor.js
with your other JavaScript files — as you probably would as a part of the minification of the scripts in your webapp. - You probably want to use the version of
arbor.js
included with Cytoscape.js (or the unpatched, original arbor.js
if you are unaffected by the issues it contains). If using npm, note that Arbor is not downloaded as an npm package automatically and needs special attention when including it as explained in the point above.
Dependencies
- Cytoscape.js ^2.4.0 || ^3.0.0
- Arbor.js >= 0.91
- jQuery, as required by Arbor
Usage instructions
Download the library:
- via npm:
npm install cytoscape-arbor
, - via bower:
bower install cytoscape-arbor
, or - via direct download in the repository (probably from a tag).
require()
the library as appropriate for your project:
CommonJS:
var cytoscape = require('cytoscape');
var cyarbor = require('cytoscape-arbor');
var arbor = require('arbor');
cyarbor( cytoscape, arbor );
AMD:
require(['cytoscape', 'cytoscape-arbor', 'arbor'], function( cytoscape, cyarbor, arbor ){
cyarbor( cytoscape, arbor );
});
Plain HTML/JS has the extension registered for you automatically, because no require()
is needed.
API
Call the layout, e.g. cy.layout({ name: 'arbor', ... })
, with the following options:
var defaults = {
animate: true,
maxSimulationTime: 4000,
fit: true,
padding: 30,
boundingBox: undefined,
ungrabifyWhileSimulating: false,
randomize: false,
ready: undefined,
stop: undefined,
repulsion: undefined,
stiffness: undefined,
friction: undefined,
gravity: true,
fps: undefined,
precision: undefined,
nodeMass: undefined,
edgeLength: undefined,
stepSize: 0.1,
stableEnergy: function( energy ){
var e = energy;
return (e.max <= 0.5) || (e.mean <= 0.3);
},
infinite: false
};
Publishing instructions
This project is set up to automatically be published to npm and bower. To publish:
- Set the version number environment variable:
export VERSION=1.2.3
- Publish:
gulp publish
- If publishing to bower for the first time, you'll need to run
bower register cytoscape-arbor https://github.com/cytoscape/cytoscape.js-arbor.git
- Make a release on GitHub to automatically register a new Zenodo DOI