GithubHelp home page GithubHelp logo

ngraph.forceatlas2's Introduction

ForceAtlas2 layout algorithm for ngraph

It's sigma.js plugin adapted for performing ngraph layout

layout example 10k nodes, 100 communities layout example 4k nodes, 2 communities layout example 4k nodes, 2 communities layout example 4k nodes, 30 communities layout example 1k nodes, 5 communities

##Usage

please see the example folder for usage details

LIVE DEMO

how to build example

npm i gulp -g && npm i && gulp watch_browserify

TODO

  • handle graph changes

ngraph.forceatlas2's People

Contributors

ziggreen avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

ngraph.forceatlas2's Issues

Weighted Graph

Hello,

Is there a way to set weight on edges with this module ?

Thank you

Cannot use this package with `ngraph.offline.layout`

Hi,

I'm hoping to use this package with ngraph.offline.layout, but I'm getting the error:

undefined:1009
    self.addEventListener('message', listener);
    ^

ReferenceError: self is not defined
    at Object.eval (eval at <anonymous> (/Users/briennakh/Documents/deaftwitter_v2/node_modules/ngraph.forceatlas2/worker.js:1116:5), <anonymous>:1009:5)
    at eval (eval at <anonymous> (/Users/briennakh/Documents/deaftwitter_v2/node_modules/ngraph.forceatlas2/worker.js:1116:5), <anonymous>:1010:4)
    at Object.<anonymous> (/Users/briennakh/Documents/deaftwitter_v2/node_modules/ngraph.forceatlas2/worker.js:1116:5)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (/Users/briennakh/Documents/deaftwitter_v2/node_modules/ngraph.forceatlas2/supervisor.js:19:16)

Full code:

/* npm install ngraph.gexf */
/* npm install ngraph.tobinary */
/* npm install ngraph.offline.layout */
/* npm install ngraph.forceatlas2 */ 
// run from root: node ./src/scripts/createGraph.js

var outDir = './src/data/'
var gexf_path = './src/data/graph.gexf'

// Load graph
console.log('Loading graph...');
var fs = require('fs');
var gexf = require('ngraph.gexf');
var graph = gexf.load(fs.readFileSync(gexf_path, 'utf8'));
console.log(graph);

// Save graph into proper format to be used in viz
console.log('Saving graph...');
var save = require('ngraph.tobinary');
save(graph, {
	outDir: outDir,
	labels: 'labels.json', 
	meta: 'meta.json',
	links: 'links.bin'
});

// Create layout and run 10 iterations of it
// https://github.com/anvaka/ngraph.offline.layout
var numIterations = 10
console.log("Running " + numIterations + " iterations of the layout...");
var createLayout = require('ngraph.offline.layout');
var layout = createLayout(graph, {
	iterations: numIterations,
	saveEach: 5, 
	outDir: outDir,
	overwrite: true, 
	layout: require('ngraph.forceatlas2') // could substitute ngraph.forcelayout
});
layout.run();

console.log('Done.');

Would it be possible to customize this package so it can be used with ngraph.offline.layout?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.