Commit 74842dd1 authored by PkSM3's avatar PkSM3

comments for fa2.js

parent 296c2e8c
// Mathieu Jacomy @ Sciences Po Médialab & WebAtlas
// Original version made by: Mathieu Jacomy @ http://github.com/jacomyal/sigma.js/blob/deprecated-v0.1/plugins/sigma.forceatlas2.js
// This is a Modified version made by Samuel Castillo.
var ForceAtlas2 = function(graph) {
var self = this;
this.graph = graph;
......@@ -830,8 +830,6 @@ var ForceAtlas2 = function(graph) {
};
};
var updateMassAndGeometry = function() {
if (this.nodes.length > 1) {
// Compute Mass
......@@ -883,7 +881,6 @@ var Region = function(nodes, depth) {
this.updateMassAndGeometry();
}
var buildSubRegions = function() {
if (this.nodes.length > 1) {
var leftNodes = [];
......@@ -957,13 +954,18 @@ var applyForce = function(n, Force, theta) {
}
};
var startForceAtlas2 = function(graph,limit_it) {
// pr("inside FA2")
//// if(!this.forceatlas2) {
// pr(graph);
// pr(graph.nodes[0].x)
// pr(graph.nodes[0].y)
// pr("--------")
// [ NEW STUFF FOR WORKERS ]
// 01. Return the values to MainContext when spatialization is finished
var startForceAtlas2 = function(graph,limit_it) {
// pr("inside FA2")
//// if(!this.forceatlas2) {
// pr(graph);
// pr(graph.nodes[0].x)
// pr(graph.nodes[0].y)
// pr("--------")
// nodes = graph.nodes;
// for(var n in nodes) {
......@@ -995,26 +997,31 @@ var startForceAtlas2 = function(graph,limit_it) {
count++;
if(flag||count>limit_it) break;
}
// pr(forceatlas2.graph.nodes[0].x)
// pr(forceatlas2.graph.nodes[0].y)
// console.log("\titerations: "+count)
// pr(forceatlas2.graph.nodes[0].x)
// pr(forceatlas2.graph.nodes[0].y)
// console.log("\titerations: "+count)
result={
"nodes":forceatlas2.graph.nodes,
"it":count
}
return result;
};
};
self.addEventListener("message", function(e) {
var graph = {
// 02. This receives the Input from MainContext. This will execute startForceAtlas2() and will "post" the returned values in MainContext.
self.addEventListener("message", function(e) {
var graph = { // Input: nodes and edges.
"nodes":e.data.nodes,
"edges":e.data.edges
}
var limit_it=e.data.it;
result=startForceAtlas2(graph,limit_it)
postMessage({
var limit_it=e.data.it; // Input: nb of iterations max.
result=startForceAtlas2(graph,limit_it) // executing Jacomy's Algo.
postMessage({ // "posting" the results in MainContext.
"nodes":result.nodes,
"it":result.it
});
}, false);
\ No newline at end of file
}, false);
// [ / NEW STUFF FOR WORKERS ]
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment