I am having very hard time understanding sigmas.js , how it works . Interested to know science behind the seen .
Reading library I understood that it renders vertices and edges on canvas .
It has an amazing code which resales the coordinate based on number of vertices and edges of graph to show all nodes .
What is maths for calculating view at applyview method https://github.com/jacomyal/sigma.js/blob/master/src/classes/sigma.classes.camera.js#L89
How apply view works :
sigma.classes.camera.prototype.applyView = function(read, write, options) {
options = options || {};
write = write !== undefined ? write : this.prefix;
read = read !== undefined ? read : this.readPrefix;
var nodes = options.nodes || this.graph.nodes(),
edges = options.edges || this.graph.edges();
var i,
l,
node,
relCos = Math.cos(this.angle) / this.ratio,
relSin = Math.sin(this.angle) / this.ratio,
nodeRatio = Math.pow(this.ratio, this.settings('nodesPowRatio')),
edgeRatio = Math.pow(this.ratio, this.settings('edgesPowRatio')),
xOffset = (options.width || 0) / 2 - this.x * relCos - this.y * relSin,
yOffset = (options.height || 0) / 2 - this.y * relCos + this.x * relSin;
for (i = 0, l = nodes.length; i < l; i++) {
node = nodes[i];
node[write + 'x'] =
(node[read + 'x'] || 0) * relCos +
(node[read + 'y'] || 0) * relSin +
xOffset;
node[write + 'y'] =
(node[read + 'y'] || 0) * relCos -
(node[read + 'x'] || 0) * relSin +
yOffset;
node[write + 'size'] =
(node[read + 'size'] || 0) /
nodeRatio;
}
for (i = 0, l = edges.length; i < l; i++) {
edges[i][write + 'size'] =
(edges[i][read + 'size'] || 0) /
edgeRatio;
}
return this;
};