ziggreen / ngraph.forceatlas2 Goto Github PK
View Code? Open in Web Editor NEWForceAtlas2 layout algorithm for ngraph
ForceAtlas2 layout algorithm for ngraph
Hello,
Is there a way to set weight on edges with this module ?
Thank you
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?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.