npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

cytoscape-arbor

v1.4.1

Published

The Arbor physics simulation layout for Cytoscape.js

Downloads

137

Readme

cytoscape-arbor

DOI

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 ); // register extension

AMD:

require(['cytoscape', 'cytoscape-arbor', 'arbor'], function( cytoscape, cyarbor, arbor ){
  cyarbor( cytoscape, arbor ); // register extension
});

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, // whether to show the layout as it's running
  maxSimulationTime: 4000, // max length in ms to run the layout
  fit: true, // on every layout reposition of nodes, fit the viewport
  padding: 30, // padding around the simulation
  boundingBox: undefined, // constrain layout bounds; { x1, y1, x2, y2 } or { x1, y1, w, h }
  ungrabifyWhileSimulating: false, // so you can't drag nodes during layout
  randomize: false, // uses random initial node positions on true

  // callbacks on layout events
  ready: undefined, // callback on layoutready
  stop: undefined, // callback on layoutstop

  // forces used by arbor (use arbor default on undefined)
  repulsion: undefined,
  stiffness: undefined,
  friction: undefined,
  gravity: true,
  fps: undefined,
  precision: undefined,

  // static numbers or functions that dynamically return what these
  // values should be for each element
  // e.g. nodeMass: function(n){ return n.data('weight') }
  nodeMass: undefined,
  edgeLength: undefined,

  stepSize: 0.1, // smoothing of arbor bounding box

  // function that returns true if the system is stable to indicate
  // that the layout can be stopped
  stableEnergy: function( energy ){
    var e = energy;
    return (e.max <= 0.5) || (e.mean <= 0.3);
  },

  // infinite layout options
  infinite: false // overrides all other options for a forces-all-the-time mode
};

Publishing instructions

This project is set up to automatically be published to npm and bower. To publish:

  1. Set the version number environment variable: export VERSION=1.2.3
  2. Publish: gulp publish
  3. 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
  4. Make a release on GitHub to automatically register a new Zenodo DOI