Commit 88a40a81 authored by Romain Loth's avatar Romain Loth

add debug traces to each function, remove trailing spaces in scripts, add...

add debug traces to each function, remove trailing spaces in scripts, add initialization call graph schema
parent 8c5a4451
// dot call_graph.dot -Tpng -o tina_call_graph.png
digraph tina_call_graph {
graph [ordering="out"];
rankdir=LR ;
edge [fontsize=10] ;
label=<<B><U>tinawebJS</U></B><BR/>(initialization callgraph)>;
labelloc="t" ;
// settings
"settings var" -> "settings:SystemStates";
"settings var" -> "settings:sigmaJsDrawingProperties";
"settings var" -> "etc.";
// getUrlParam
"t.globalUtils:getUrlParam" -> "var mainfile (url)" ;
// main 1: get graph
"t.main" -> "var mainfile (url)" ;
"var mainfile (url)" -> "ajax garg" ;
"ajax garg" -> "t.main:MainFunction" ;
// main 2: parse graph
"t.main:MainFunction" -> "t.sigma.parseCustom:ParseCustom" ;
"t.main:MainFunction" -> "t.sigma.parseCustom:scanFile" ;
"t.sigma.parseCustom:scanFile" -> "t.sigma.parseCustom:getJSONCategories" ;
"t.sigma.parseCustom:getJSONCategories" -> "t.sigma.parseCustom:scanJSON" ;
"t.main:MainFunction" -> "t.sigma.parseCustom:makeSystemStates" ;
"t.main:MainFunction" -> "t.sigma.parseCustom:buildInitialState" ;
"t.main:MainFunction" -> "t.sigma.parseCustom:makeDicts" ;
"t.sigma.parseCustom:makeDicts" -> "t.sigma.parseCustom:dictfyJSON" [label="cats={'terms':0}"] ;
// main 3: new TinaWebJS()
"t.main:MainFunction" -> "var twjs_" ;
"var twjs_" -> "t.TinawebJS:TinaWebJS:new" ;
// main 4: adjust canvas routine
"t.main:MainFunction" -> "t.TinawebJS:AdjustSigmaCanvas" ; // twjs_.AdjustSigmaCanvas()
"t.TinawebJS:AdjustSigmaCanvas" -> "t.TinawebJS:sigmaLimits" ;
"t.TinawebJS:sigmaLimits" -> "t.TinawebJS:visibleHeight" ;
"t.TinawebJS:sigmaLimits" -> "new canvas!" ;
// main 5: partialGraph and new SigmaUtils()
"t.main:MainFunction" -> "var partialGraph" ;
"var partialGraph" -> "sigma:init";
"t.main:MainFunction" -> "t.SigmaUtils:SigmaUtils:new" ;
"t.main:MainFunction" -> "t.SigmaUtils:SigmaUtils:FillGraph" ; // [ Poblating the Sigma-Graph ]
"t.SigmaUtils:SigmaUtils:FillGraph" -> "SigmaPublic.addNode" [label="x N"];
"t.SigmaUtils:SigmaUtils:FillGraph" -> "SigmaPublic.addEdge" [label="x N"];
"SigmaPublic.addEdge" -> "t.globalUtils:hex2rga" [label="x M"];
"t.SigmaUtils:SigmaUtils:FillGraph" -> "t.enviroment:updateSearchLabels" [label="N x push labels"];
// main 6: state and settings for partialGraph
// "settings:sigmaJsDrawingProperties" -> "var partialGraph" ;
// "settings:SystemStates" -> "var partialGraph" ;
"var partialGraph" -> "t.main:partialGraph:setState";
// main 7: twjs_.initListeners( categories , partialGraph)
"t.main:MainFunction" -> "t.TinawebJS:initListeners" ;
"t.TinawebJS:initListeners" -> "t.TinawebJS:SelectionEngine:new" [label="initListeners:SelInst"] ;
"t.TinawebJS:initListeners" -> "onclick:#changetype" ;
"t.TinawebJS:initListeners" -> "onclick:#changelevel" ;
"t.TinawebJS:initListeners" -> "onclick:#aUnfold" ;
"t.TinawebJS:initListeners" -> "t.minimap:startMiniMap" [label = "if minimap"] ;
"t.TinawebJS:initListeners" -> "t.methods:pushSWClick" [label = "var swclickActual"] ;
"t.TinawebJS:initListeners" -> "t.methods:cancelSelection" ;
"t.methods:cancelSelection" -> "t.methods:highlightSelectedNodes" [label = "false"] ;
"t.methods:highlightSelectedNodes" -> "t.globalUtils:is_empty" ;
"t.methods:cancelSelection" -> "erase:#names" ;
"t.methods:cancelSelection" -> "erase:#ngrams_actions" ;
"t.methods:cancelSelection" -> "erase:#topPapers" ;
"t.methods:cancelSelection" -> "erase:#opossiteNodes" ;
"t.methods:cancelSelection" -> "erase:#searchinput" ;
"t.methods:cancelSelection" -> "t.methods:LevelButtonDisable" ;
"t.TinawebJS:initListeners" -> "t.sigmaUtils:showMeSomeLabels" ;
"t.sigmaUtils:showMeSomeLabels" -> "t.sigmaUtils:getVisibleNodes" ;
"t.TinawebJS:initListeners" -> "t.TinawebJS:SearchListeners" ;
"t.TinawebJS:SearchListeners" -> "autocomplete:#searchinput" ;
"autocomplete:#searchinput" -> "t.TinawebJS:SelectionEngine:new" [label="SearchListeners:SelInst"] ;
/*t.methods:highlightSelectedNodes*/
}
partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.2).draw();
SystemStates
// {
// "level": true,
// "type": [
// true
// ],
// "selections": [],
// "opposites": [],
// "categories": [
// "terms"
// ],
// "categoriesDict": {
// "terms": "0"
// },
// "LouvainFait": false
// }
This diff is collapsed.
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
* Customize as you want ;) * Customize as you want ;)
*/ */
console.log('FUN settings_explorerjs:main')
// ============ < DEVELOPER OPTIONS > ============ // ============ < DEVELOPER OPTIONS > ============
var geomap=false; var geomap=false;
var colorByAtt = false; var colorByAtt = false;
...@@ -78,7 +80,7 @@ var SigmaUtils = function () {}; ...@@ -78,7 +80,7 @@ var SigmaUtils = function () {};
var TinaWebJS = function () {}; var TinaWebJS = function () {};
var Relations = {} var Relations = {}
var SystemStates = {} var SystemStates = {}
SystemStates.level = true; SystemStates.level = true;
...@@ -116,7 +118,7 @@ var desirableScholarSize=6; //Remember that all scholars have the same size! ...@@ -116,7 +118,7 @@ var desirableScholarSize=6; //Remember that all scholars have the same size!
*Three states: *Three states:
* - true: fa2 running at start * - true: fa2 running at start
* - false: fa2 stopped at start, button exists * - false: fa2 stopped at start, button exists
* - "off": button doesn't exist, fa2 stopped forever * - "off": button doesn't exist, fa2 stopped forever
**/ var fa2enabled=false;//"off"; **/ var fa2enabled=false;//"off";
var stopcriteria = false; var stopcriteria = false;
var iterationsFA2=1000; var iterationsFA2=1000;
...@@ -152,7 +154,7 @@ var sigmaJsMouseProperties = { ...@@ -152,7 +154,7 @@ var sigmaJsMouseProperties = {
maxRatio: 50 maxRatio: 50
}; };
// ============ < / SIGMA.JS PROPERTIES > ============ // ============ < / SIGMA.JS PROPERTIES > ============
// ============ < / DEVELOPER OPTIONS > ============ // ============ < / DEVELOPER OPTIONS > ============
...@@ -198,14 +200,14 @@ var overviewScale = 0.25; ...@@ -198,14 +200,14 @@ var overviewScale = 0.25;
var overviewHover=false; var overviewHover=false;
var moveDelay = 80, zoomDelay = 2; var moveDelay = 80, zoomDelay = 2;
//var Vecindad; //var Vecindad;
var partialGraph; var partialGraph;
var otherGraph; var otherGraph;
var Nodes = []; var Nodes = [];
var Edges = []; var Edges = [];
var nodeslength=0; var nodeslength=0;
var labels = []; var labels = [];
var numberOfDocs=0; var numberOfDocs=0;
var numberOfNGrams=0; var numberOfNGrams=0;
...@@ -268,4 +270,3 @@ var RVUniformC = function(seed){ ...@@ -268,4 +270,3 @@ var RVUniformC = function(seed){
}; };
} }
//unifCont = new RVUniformC(100000000) //unifCont = new RVUniformC(100000000)
function scanDataFolder(){ function scanDataFolder(){
console.log('FUN t.DataScanner:scanDataFolder')
$.ajax({ $.ajax({
type: 'GET', type: 'GET',
url: 'php/DirScan_main.php', url: 'php/DirScan_main.php',
//data: "type="+type+"&query="+jsonparams, //data: "type="+type+"&query="+jsonparams,
//contentType: "application/json", //contentType: "application/json",
//dataType: 'json', //dataType: 'json',
success : function(data){ success : function(data){
console.log(data); console.log(data);
dataFolderTree=data; dataFolderTree=data;
}, },
error: function(){ error: function(){
console.log('Page Not found: updateLeftPanel_uni()'); console.log('Page Not found: updateLeftPanel_uni()');
} }
}); });
} }
function getGexfPath(v){ function getGexfPath(v){
console.log('FUN t.DataScanner:getGexfPath')
gexfpath=(gexfDictReverse[v])?gexfDictReverse[v]:v; gexfpath=(gexfDictReverse[v])?gexfDictReverse[v]:v;
return gexfpath; return gexfpath;
} }
function getGexfLegend(gexfPath){ function getGexfLegend(gexfPath){
console.log('FUN t.DataScanner:getGexfLegend')
legend=(gexfDict[gexfPath])?gexfDict[gexfPath]:gexfPath; legend=(gexfDict[gexfPath])?gexfDict[gexfPath]:gexfPath;
return legend; return legend;
} }
function jsActionOnGexfSelector(gexfLegend){ function jsActionOnGexfSelector(gexfLegend){
console.log('FUN t.DataScanner:jsActionOnGexfSelector')
if(getGexfPath[gexfLegend]) if(getGexfPath[gexfLegend])
window.location=window.location.origin+window.location.pathname+"?file="+encodeURIComponent(getGexfPath(gexfLegend)); window.location=window.location.origin+window.location.pathname+"?file="+encodeURIComponent(getGexfPath(gexfLegend));
else else
...@@ -34,6 +38,7 @@ function jsActionOnGexfSelector(gexfLegend){ ...@@ -34,6 +38,7 @@ function jsActionOnGexfSelector(gexfLegend){
} }
function listGexfs(){ function listGexfs(){
console.log('FUN t.DataScanner:listGexfs')
divlen=$("#gexfs").length; divlen=$("#gexfs").length;
if(divlen>0) { if(divlen>0) {
param = JSON.stringify(gexfDict); param = JSON.stringify(gexfDict);
...@@ -42,7 +47,7 @@ function listGexfs(){ ...@@ -42,7 +47,7 @@ function listGexfs(){
url: 'php/listFiles.php', url: 'php/listFiles.php',
//contentType: "application/json", //contentType: "application/json",
//dataType: 'json', //dataType: 'json',
success : function(data){ success : function(data){
html="<select style='width:150px;' "; html="<select style='width:150px;' ";
javs='onchange="'+'jsActionOnGexfSelector(this.value);'+'"'; javs='onchange="'+'jsActionOnGexfSelector(this.value);'+'"';
html+=javs; html+=javs;
...@@ -57,9 +62,9 @@ function listGexfs(){ ...@@ -57,9 +62,9 @@ function listGexfs(){
html+="</select>"; html+="</select>";
$("#gexfs").html(html); $("#gexfs").html(html);
}, },
error: function(){ error: function(){
console.log("Page Not found."); console.log("Page Not found.");
} }
}); });
} }
} }
This diff is collapsed.
// Mathieu Jacomy @ Sciences Po Médialab & WebAtlas // Mathieu Jacomy @ Sciences Po Médialab & WebAtlas
var ForceAtlas2 = function(graph) { var ForceAtlas2 = function(graph) {
console.log('FUN t.asyncFA2:ForceAtlas2')
var self = this; var self = this;
this.graph = graph; this.graph = graph;
...@@ -31,6 +32,7 @@ var ForceAtlas2 = function(graph) { ...@@ -31,6 +32,7 @@ var ForceAtlas2 = function(graph) {
// Runtime (the ForceAtlas2 itself) // Runtime (the ForceAtlas2 itself)
this.init = function() { this.init = function() {
console.log('FUN t.asyncFA2:init')
self.state = {step: 0, index: 0}; self.state = {step: 0, index: 0};
self.graph.nodes.forEach(function(n) { self.graph.nodes.forEach(function(n) {
n.fa2 = { n.fa2 = {
...@@ -46,10 +48,12 @@ var ForceAtlas2 = function(graph) { ...@@ -46,10 +48,12 @@ var ForceAtlas2 = function(graph) {
} }
this.go = function() { this.go = function() {
console.log('FUN t.asyncFA2:go')
while (self.onebucle()) {} while (self.onebucle()) {}
} }
this.onebucle = function() { this.onebucle = function() {
console.log('FUN t.asyncFA2:onebucle')
var graph = self.graph; var graph = self.graph;
var nodes = graph.nodes; var nodes = graph.nodes;
var edges = graph.edges; var edges = graph.edges;
...@@ -233,7 +237,7 @@ var ForceAtlas2 = function(graph) { ...@@ -233,7 +237,7 @@ var ForceAtlas2 = function(graph) {
totalSwinging += n.fa2.mass * swinging; totalSwinging += n.fa2.mass * swinging;
swingingSum += swinging; swingingSum += swinging;
promdxdy += (Math.abs(n.fa2.dx)+Math.abs(n.fa2.dy))/2; /**/ promdxdy += (Math.abs(n.fa2.dx)+Math.abs(n.fa2.dy))/2; /**/
totalEffectiveTraction += n.fa2.mass * totalEffectiveTraction += n.fa2.mass *
0.5 * 0.5 *
Math.sqrt( Math.sqrt(
...@@ -242,15 +246,15 @@ var ForceAtlas2 = function(graph) { ...@@ -242,15 +246,15 @@ var ForceAtlas2 = function(graph) {
); );
} }
}); });
self.p.totalSwinging = totalSwinging; self.p.totalSwinging = totalSwinging;
var convg= ((Math.pow(nodes.length,2))/promdxdy); /**/ var convg= ((Math.pow(nodes.length,2))/promdxdy); /**/
var swingingVSnodes_length = swingingSum/nodes.length; /**/ var swingingVSnodes_length = swingingSum/nodes.length; /**/
// if(convg > swingingVSnodes_length){ // if(convg > swingingVSnodes_length){
// self.p.banderita=true; // self.p.banderita=true;
// } // }
self.p.totalEffectiveTraction = totalEffectiveTraction; self.p.totalEffectiveTraction = totalEffectiveTraction;
// We want that swingingMovement < tolerance * convergenceMovement // We want that swingingMovement < tolerance * convergenceMovement
...@@ -346,6 +350,7 @@ var ForceAtlas2 = function(graph) { ...@@ -346,6 +350,7 @@ var ForceAtlas2 = function(graph) {
} }
this.end = function() { this.end = function() {
console.log('FUN t.asyncFA2:end')
this.graph.nodes.forEach(function(n) { this.graph.nodes.forEach(function(n) {
n.fa2 = null; n.fa2 = null;
}); });
...@@ -353,6 +358,7 @@ var ForceAtlas2 = function(graph) { ...@@ -353,6 +358,7 @@ var ForceAtlas2 = function(graph) {
// Auto Settings // Auto Settings
this.setAutoSettings = function() { this.setAutoSettings = function() {
console.log('FUN t.asyncFA2:setAutoSettings')
var graph = this.graph; var graph = this.graph;
// Tuning // Tuning
...@@ -833,6 +839,7 @@ var ForceAtlas2 = function(graph) { ...@@ -833,6 +839,7 @@ var ForceAtlas2 = function(graph) {
var updateMassAndGeometry = function() { var updateMassAndGeometry = function() {
console.log('FUN t.asyncFA2:updateMassAndGeometry')
if (this.nodes.length > 1) { if (this.nodes.length > 1) {
// Compute Mass // Compute Mass
var mass = 0; var mass = 0;
...@@ -878,13 +885,14 @@ var Region = function(nodes, depth) { ...@@ -878,13 +885,14 @@ var Region = function(nodes, depth) {
massCenterX: 0, massCenterX: 0,
massCenterY: 0 massCenterY: 0
}; };
console.log("updating mass and geometry"); console.log("updating mass and geometry");
this.updateMassAndGeometry(); this.updateMassAndGeometry();
} }
var buildSubRegions = function() { var buildSubRegions = function() {
console.log('FUN t.asyncFA2:buildSubRegions')
if (this.nodes.length > 1) { if (this.nodes.length > 1) {
var leftNodes = []; var leftNodes = [];
var rightNodes = []; var rightNodes = [];
...@@ -936,6 +944,7 @@ var buildSubRegions = function() { ...@@ -936,6 +944,7 @@ var buildSubRegions = function() {
}; };
var applyForce = function(n, Force, theta) { var applyForce = function(n, Force, theta) {
console.log('FUN t.asyncFA2:applyForce')
if (this.nodes.length < 2) { if (this.nodes.length < 2) {
var regionNode = this.nodes[0]; var regionNode = this.nodes[0];
Force.apply_nn(n, regionNode); Force.apply_nn(n, regionNode);
...@@ -958,6 +967,7 @@ var applyForce = function(n, Force, theta) { ...@@ -958,6 +967,7 @@ var applyForce = function(n, Force, theta) {
}; };
var startForceAtlas2 = function(graph,limit_it) { var startForceAtlas2 = function(graph,limit_it) {
console.log('FUN t.asyncFA2:startForceAtlas2')
// pr("inside FA2") // pr("inside FA2")
//// if(!this.forceatlas2) { //// if(!this.forceatlas2) {
// pr(graph); // pr(graph);
...@@ -981,7 +991,7 @@ var startForceAtlas2 = function(graph,limit_it) { ...@@ -981,7 +991,7 @@ var startForceAtlas2 = function(graph,limit_it) {
forceatlas2 = new ForceAtlas2(graph); forceatlas2 = new ForceAtlas2(graph);
forceatlas2.setAutoSettings(); forceatlas2.setAutoSettings();
forceatlas2.init(); forceatlas2.init();
count=0; count=0;
flag=false; flag=false;
while(true){ while(true){
...@@ -994,13 +1004,13 @@ var startForceAtlas2 = function(graph,limit_it) { ...@@ -994,13 +1004,13 @@ var startForceAtlas2 = function(graph,limit_it) {
} }
count++; count++;
if(flag||count>limit_it) break; if(flag||count>limit_it) break;
} }
// pr(forceatlas2.graph.nodes[0].x) // pr(forceatlas2.graph.nodes[0].x)
// pr(forceatlas2.graph.nodes[0].y) // pr(forceatlas2.graph.nodes[0].y)
// console.log("\titerations: "+count) // console.log("\titerations: "+count)
result={ result={
"nodes":forceatlas2.graph.nodes, "nodes":forceatlas2.graph.nodes,
"it":count "it":count
} }
return result; return result;
}; };
...@@ -1016,5 +1026,5 @@ self.addEventListener("message", function(e) { ...@@ -1016,5 +1026,5 @@ self.addEventListener("message", function(e) {
"nodes":result.nodes, "nodes":result.nodes,
"it":result.it "it":result.it
}); });
}, false); }, false);
\ No newline at end of file
This diff is collapsed.
...@@ -10,6 +10,7 @@ function print(msg) { ...@@ -10,6 +10,7 @@ function print(msg) {
//to general utils //to general utils
function getClientTime(){ function getClientTime(){
console.log('FUN t.globalUtils:getClientTime')
var totalSec = new Date().getTime() / 1000; var totalSec = new Date().getTime() / 1000;
var d = new Date(); var d = new Date();
var hours = d.getHours(); var hours = d.getHours();
...@@ -20,11 +21,13 @@ function getClientTime(){ ...@@ -20,11 +21,13 @@ function getClientTime(){
} }
function compareNumbers(a, b) { function compareNumbers(a, b) {
console.log('FUN t.globalUtils:compareNumbers')
return a - b; return a - b;
} }
//python range(a,b) | range(a) //python range(a,b) | range(a)
function calc_range(begin, end) { function calc_range(begin, end) {
console.log('FUN t.globalUtils:calc_range')
if (typeof end === "undefined") { if (typeof end === "undefined") {
end = begin; begin = 0; end = begin; begin = 0;
} }
...@@ -38,6 +41,7 @@ function calc_range(begin, end) { ...@@ -38,6 +41,7 @@ function calc_range(begin, end) {
//to general utils (not used btw) //to general utils (not used btw)
function cloneObject(source) { function cloneObject(source) {
console.log('FUN t.globalUtils:cloneObject')
for (i in source) { for (i in source) {
if (typeof source[i] == 'source') { if (typeof source[i] == 'source') {
this[i] = new cloneObject(source[i]); this[i] = new cloneObject(source[i]);
...@@ -49,14 +53,16 @@ function cloneObject(source) { ...@@ -49,14 +53,16 @@ function cloneObject(source) {
} }
function isUndef(variable){ function isUndef(variable){
// console.log('FUN t.globalUtils:isUndef')
if(typeof(variable)==="undefined") return true; if(typeof(variable)==="undefined") return true;
else return false; else return false;
} }
$.fn.toggleClick = function(){ $.fn.toggleClick = function(){
console.log('FUN t.globalUtils:toggleClick')
methods = arguments, // store the passed arguments for future reference methods = arguments, // store the passed arguments for future reference
count = methods.length; // cache the number of methods count = methods.length; // cache the number of methods
//use return this to maintain jQuery chainability //use return this to maintain jQuery chainability
return this.each(function(i, item){ return this.each(function(i, item){
...@@ -71,6 +77,7 @@ $.fn.toggleClick = function(){ ...@@ -71,6 +77,7 @@ $.fn.toggleClick = function(){
getUrlParam = (function () { getUrlParam = (function () {
console.log('FUN t.globalUtils:getUrlParam')
var get = { var get = {
push:function (key,value){ push:function (key,value){
var cur = this[key]; var cur = this[key];
...@@ -101,12 +108,13 @@ getUrlParam = (function () { ...@@ -101,12 +108,13 @@ getUrlParam = (function () {
function ArraySortByValue(array, sortFunc){ function ArraySortByValue(array, sortFunc){
console.log('FUN t.globalUtils:ArraySortByValue')
var tmp = []; var tmp = [];
oposMAX=0; oposMAX=0;
for (var k in array) { for (var k in array) {
if (array.hasOwnProperty(k)) { if (array.hasOwnProperty(k)) {
tmp.push({ tmp.push({
key: k, key: k,
value: array[k] value: array[k]
}); });
if((array[k]) > oposMAX) oposMAX= array[k]; if((array[k]) > oposMAX) oposMAX= array[k];
...@@ -115,18 +123,19 @@ function ArraySortByValue(array, sortFunc){ ...@@ -115,18 +123,19 @@ function ArraySortByValue(array, sortFunc){
tmp.sort(function(o1, o2) { tmp.sort(function(o1, o2) {
return sortFunc(o1.value, o2.value); return sortFunc(o1.value, o2.value);
}); });
return tmp; return tmp;
} }
function ArraySortByKey(array, sortFunc){ function ArraySortByKey(array, sortFunc){
console.log('FUN t.globalUtils:ArraySortByKey')
var tmp = []; var tmp = [];
for (var k in array) { for (var k in array) {
if (array.hasOwnProperty(k)) { if (array.hasOwnProperty(k)) {
tmp.push({ tmp.push({
key: k, key: k,
value: array[k] value: array[k]
}); });
} }
...@@ -134,12 +143,13 @@ function ArraySortByKey(array, sortFunc){ ...@@ -134,12 +143,13 @@ function ArraySortByKey(array, sortFunc){
tmp.sort(function(o1, o2) { tmp.sort(function(o1, o2) {
return sortFunc(o1.key, o2.key); return sortFunc(o1.key, o2.key);
}); });
return tmp; return tmp;
} }
function is_empty(obj) { function is_empty(obj) {
console.log('FUN t.globalUtils:is_empty')
// Assume if it has a length property with a non-zero value // Assume if it has a length property with a non-zero value
// that that property is correct. // that that property is correct.
if (obj.length && obj.length > 0) return false; if (obj.length && obj.length > 0) return false;
...@@ -153,12 +163,14 @@ function is_empty(obj) { ...@@ -153,12 +163,14 @@ function is_empty(obj) {
function getByID(elem) { function getByID(elem) {
console.log('FUN t.globalUtils:getByID')
return document.getElementById(elem); return document.getElementById(elem);
} }
function hex2rga(sent_hex) { function hex2rga(sent_hex) {
// console.log('FUN t.globalUtils:hex2rga')
result = [] result = []
hex = ( sent_hex.charAt(0) === "#" ? sent_hex.substr(1) : sent_hex ); hex = ( sent_hex.charAt(0) === "#" ? sent_hex.substr(1) : sent_hex );
// check if 6 letters are provided // check if 6 letters are provided
...@@ -173,6 +185,7 @@ function hex2rga(sent_hex) { ...@@ -173,6 +185,7 @@ function hex2rga(sent_hex) {
} }
function calculateFull(hex) { function calculateFull(hex) {
// console.log('FUN t.globalUtils:calculateFull')
var r = parseInt(hex.substring(0, 2), 16); var r = parseInt(hex.substring(0, 2), 16);
var g = parseInt(hex.substring(2, 4), 16); var g = parseInt(hex.substring(2, 4), 16);
var b = parseInt(hex.substring(4, 6), 16); var b = parseInt(hex.substring(4, 6), 16);
...@@ -182,6 +195,7 @@ function calculateFull(hex) { ...@@ -182,6 +195,7 @@ function calculateFull(hex) {
// function for calculating 3 letters hex value // function for calculating 3 letters hex value
function calculatePartial(hex) { function calculatePartial(hex) {
console.log('FUN t.globalUtils:calculatePartial')
var r = parseInt(hex.substring(0, 1) + hex.substring(0, 1), 16); var r = parseInt(hex.substring(0, 1) + hex.substring(0, 1), 16);
var g = parseInt(hex.substring(1, 2) + hex.substring(1, 2), 16); var g = parseInt(hex.substring(1, 2) + hex.substring(1, 2), 16);
var b = parseInt(hex.substring(2, 3) + hex.substring(2, 3), 16); var b = parseInt(hex.substring(2, 3) + hex.substring(2, 3), 16);
...@@ -189,27 +203,31 @@ function calculatePartial(hex) { ...@@ -189,27 +203,31 @@ function calculatePartial(hex) {
} }
function componentToHex(c) { function componentToHex(c) {
console.log('FUN t.globalUtils:componentToHex')
var hex = c.toString(16); var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex; return hex.length == 1 ? "0" + hex : hex;
} }
function rgbToHex(r, g, b) { function rgbToHex(r, g, b) {
console.log('FUN t.globalUtils:rgbToHex')
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b); return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
} }
/** /**
* function to load a given css file * function to load a given css file
*/ */
loadCSS = function(href) { loadCSS = function(href) {
console.log('FUN t.globalUtils:loadCSS')
var cssLink = $("<link rel='stylesheet' type='text/css' href='"+href+"'>"); var cssLink = $("<link rel='stylesheet' type='text/css' href='"+href+"'>");
$("head").append(cssLink); $("head").append(cssLink);
}; };
/** /**
* function to load a given js file * function to load a given js file
*/ */
loadJS = function(src) { loadJS = function(src) {
console.log('FUN t.globalUtils:loadJS')
var jsLink = $("<script type='text/javascript' src='"+src+"'>"); var jsLink = $("<script type='text/javascript' src='"+src+"'>");
$("head").append(jsLink); $("head").append(jsLink);
}; };
\ No newline at end of file
/* /*
Author: Corneliu S. (github.com/upphiminn) Author: Corneliu S. (github.com/upphiminn)
This is a javascript implementation of the Louvain This is a javascript implementation of the Louvain
community detection algorithm (http://arxiv.org/abs/0803.0476) community detection algorithm (http://arxiv.org/abs/0803.0476)
Based on https://bitbucket.org/taynaud/python-louvain/overview Based on https://bitbucket.org/taynaud/python-louvain/overview
*/ */
(function(){ (function(){
jLouvain = function(){ jLouvain = function(){
console.log('FUN t.jLouvain:jLouvain')
//Constants //Constants
var __PASS_MAX = -1 var __PASS_MAX = -1
var __MIN = 0.0000001 var __MIN = 0.0000001
...@@ -48,16 +49,16 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -48,16 +49,16 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
}); });
return weight; return weight;
}; };
function get_neighbours_of_node(graph, node){ function get_neighbours_of_node(graph, node){
if(typeof graph._assoc_mat[node] == 'undefined') if(typeof graph._assoc_mat[node] == 'undefined')
return []; return [];
var neighbours = Object.keys(graph._assoc_mat[node]); var neighbours = Object.keys(graph._assoc_mat[node]);
return neighbours; return neighbours;
} }
function get_edge_weight(graph, node1, node2){ function get_edge_weight(graph, node1, node2){
return graph._assoc_mat[node1] ? graph._assoc_mat[node1][node2] : undefined; return graph._assoc_mat[node1] ? graph._assoc_mat[node1][node2] : undefined;
} }
...@@ -113,8 +114,9 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -113,8 +114,9 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
return temp; return temp;
} }
//Core-Algorithm Related //Core-Algorithm Related
function init_status(graph, status, part){ function init_status(graph, status, part){
console.log('FUN t.jLouvain:init_status')
status['nodes_to_com'] = {}; status['nodes_to_com'] = {};
status['total_weight'] = 0; status['total_weight'] = 0;
status['internals'] = {}; status['internals'] = {};
...@@ -184,13 +186,13 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -184,13 +186,13 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
var weights = {}; var weights = {};
var neighboorhood = get_neighbours_of_node(graph, node);//make iterable; var neighboorhood = get_neighbours_of_node(graph, node);//make iterable;
neighboorhood.forEach(function(neighbour, i){ neighboorhood.forEach(function(neighbour, i){
if(neighbour != node){ if(neighbour != node){
var weight = graph._assoc_mat[node][neighbour] || 1; var weight = graph._assoc_mat[node][neighbour] || 1;
var neighbourcom = status.nodes_to_com[neighbour]; var neighbourcom = status.nodes_to_com[neighbour];
weights[neighbourcom] = (weights[neighbourcom] || 0) + weight; weights[neighbourcom] = (weights[neighbourcom] || 0) + weight;
} }
}); });
return weights; return weights;
...@@ -212,7 +214,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -212,7 +214,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
function __renumber(dict){ function __renumber(dict){
var count = 0; var count = 0;
var ret = clone(dict); //deep copy :) var ret = clone(dict); //deep copy :)
var new_values = {}; var new_values = {};
var dict_keys = Object.keys(dict); var dict_keys = Object.keys(dict);
dict_keys.forEach(function(key){ dict_keys.forEach(function(key){
...@@ -255,7 +257,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -255,7 +257,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
best_increase = incr; best_increase = incr;
best_com = com; best_com = com;
} }
}); });
__insert(node, best_com, neigh_communities[best_com] || 0, status); __insert(node, best_com, neigh_communities[best_com] || 0, status);
...@@ -269,6 +271,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -269,6 +271,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
} }
function induced_graph(partition, graph){ function induced_graph(partition, graph){
console.log('FUN t.jLouvain:induced_graph')
var ret = {nodes:[], edges:[], _assoc_mat: {}}; var ret = {nodes:[], edges:[], _assoc_mat: {}};
var w_prec, weight; var w_prec, weight;
//add nodes from partition values //add nodes from partition values
...@@ -278,7 +281,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -278,7 +281,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
weight = edge.weight || 1; weight = edge.weight || 1;
var com1 = partition[edge.source]; var com1 = partition[edge.source];
var com2 = partition[edge.target]; var com2 = partition[edge.target];
w_prec = (get_edge_weight(ret, com1, com2) || 0); w_prec = (get_edge_weight(ret, com1, com2) || 0);
var new_weight = (w_prec + weight); var new_weight = (w_prec + weight);
add_edge_to_graph(ret, {'source': com1, 'target': com2, 'weight': new_weight}); add_edge_to_graph(ret, {'source': com1, 'target': com2, 'weight': new_weight});
}); });
...@@ -286,6 +289,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -286,6 +289,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
} }
function partition_at_level(dendogram, level){ function partition_at_level(dendogram, level){
console.log('FUN t.jLouvain:partition_at_level')
var partition = clone(dendogram[0]); var partition = clone(dendogram[0]);
for(var i = 1; i < level + 1; i++ ) for(var i = 1; i < level + 1; i++ )
Object.keys(partition).forEach(function(key,j){ Object.keys(partition).forEach(function(key,j){
...@@ -298,7 +302,8 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -298,7 +302,8 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
function generate_dendogram(graph, part_init){ function generate_dendogram(graph, part_init){
console.log('FUN t.jLouvain:generate_dendogram')
if(graph.edges.length == 0){ if(graph.edges.length == 0){
var part = {}; var part = {};
graph.nodes.forEach(function(node,i){ graph.nodes.forEach(function(node,i){
...@@ -326,14 +331,14 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -326,14 +331,14 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
break; break;
partition = __renumber(status.nodes_to_com); partition = __renumber(status.nodes_to_com);
status_list.push(partition); status_list.push(partition);
mod = new_mod; mod = new_mod;
current_graph = induced_graph(partition, current_graph); current_graph = induced_graph(partition, current_graph);
init_status(current_graph, status); init_status(current_graph, status);
} }
return status_list; return status_list;
} }
var core = function(){ var core = function(){
...@@ -361,7 +366,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -361,7 +366,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
'_assoc_mat': assoc_mat }; '_assoc_mat': assoc_mat };
} }
return core; return core;
}; };
core.partition_init = function(prttn){ core.partition_init = function(prttn){
...@@ -373,4 +378,4 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview ...@@ -373,4 +378,4 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
return core; return core;
} }
})(); })();
\ No newline at end of file
...@@ -38,18 +38,18 @@ var AjaxSync = (function(TYPE, URL, DATA, CT , DT) { ...@@ -38,18 +38,18 @@ var AjaxSync = (function(TYPE, URL, DATA, CT , DT) {
header = (header)?"json":"gexf"; header = (header)?"json":"gexf";
Result = { "OK":true , "format":header , "data":data }; Result = { "OK":true , "format":header , "data":data };
}, },
error: function(exception) { error: function(exception) {
Result = { "OK":false , "format":false , "data":exception.status }; Result = { "OK":false , "format":false , "data":exception.status };
} }
}); });
return Result; return Result;
}).index(); }).index();
var urlfile_override = (isUndef(getUrlParam.file))?false:true; var urlfile_override = (isUndef(getUrlParam.file))?false:true;
var files_selector = "" var files_selector = ""
if(urlfile_override) if(urlfile_override)
mainfile.unshift( getUrlParam.file ); mainfile.unshift( getUrlParam.file );
unique_mainfile = mainfile.filter(function(item, pos) { unique_mainfile = mainfile.filter(function(item, pos) {
...@@ -79,13 +79,16 @@ $.ajax({ ...@@ -79,13 +79,16 @@ $.ajax({
Result = { "OK":true , "format":header , "data":data }; Result = { "OK":true , "format":header , "data":data };
MainFunction( Result ) MainFunction( Result )
}, },
error: function(exception) { error: function(exception) {
Result = { "OK":false , "format":false , "data":exception.status }; Result = { "OK":false , "format":false , "data":exception.status };
MainFunction( Result ) MainFunction( Result )
} }
}); });
function MainFunction( RES ) { function MainFunction( RES ) {
console.log(' ------------')
console.log('FUN t.main:MainFunction')
console.log(' ------------')
if(!RES["OK"]) { if(!RES["OK"]) {
alert("error: "+RES["data"]) alert("error: "+RES["data"])
return false; return false;
...@@ -94,7 +97,7 @@ function MainFunction( RES ) { ...@@ -94,7 +97,7 @@ function MainFunction( RES ) {
var fileparam;// = { db|api.json , somefile.json|gexf } var fileparam;// = { db|api.json , somefile.json|gexf }
var the_data = RES["data"]; var the_data = RES["data"];
if(file=="db.json") { if(file=="db.json") {
getAdditionalInfo = true; getAdditionalInfo = true;
...@@ -126,7 +129,7 @@ function MainFunction( RES ) { ...@@ -126,7 +129,7 @@ function MainFunction( RES ) {
pr(the_data.length) pr(the_data.length)
pr(fileparam) pr(fileparam)
pr("\n============================\n") pr("\n============================\n")
} }
if (file=="api.json") { if (file=="api.json") {
fileparam = file; fileparam = file;
...@@ -136,7 +139,7 @@ function MainFunction( RES ) { ...@@ -136,7 +139,7 @@ function MainFunction( RES ) {
if ( file!="db.json" && file!="api.json" ) if ( file!="db.json" && file!="api.json" )
fileparam = RES["format"]; fileparam = RES["format"];
start = new ParseCustom( fileparam , the_data ); start = new ParseCustom( fileparam , the_data );
categories = start.scanFile(); //user should choose the order of categories categories = start.scanFile(); //user should choose the order of categories
pr("Categories: ") pr("Categories: ")
...@@ -161,11 +164,11 @@ function MainFunction( RES ) { ...@@ -161,11 +164,11 @@ function MainFunction( RES ) {
for(var i in categories) { for(var i in categories) {
Filters[i] = {} Filters[i] = {}
Filters[i]["#slidercat"+i+"edgesweight"] = true; Filters[i]["#slidercat"+i+"edgesweight"] = true;
} }
// [ Initiating Sigma-Canvas ] // [ Initiating Sigma-Canvas ]
var twjs_ = new TinaWebJS('#sigma-example'); var twjs_ = new TinaWebJS('#sigma-example');
print( twjs_.AdjustSigmaCanvas() ); print( twjs_.AdjustSigmaCanvas() );
$( window ).resize(function() { print(twjs_.AdjustSigmaCanvas()) }); $( window ).resize(function() { print(twjs_.AdjustSigmaCanvas()) });
// [ / Initiating Sigma-Canvas ] // [ / Initiating Sigma-Canvas ]
...@@ -217,7 +220,7 @@ function MainFunction( RES ) { ...@@ -217,7 +220,7 @@ function MainFunction( RES ) {
var past = partialGraph.states.slice(-2)[0] // avant Last var past = partialGraph.states.slice(-2)[0] // avant Last
print("previous level: "+past.level) print("previous level: "+past.level)
print("new level: "+present.level) print("new level: "+present.level)
print(" % % % % % % % % % % ") print(" % % % % % % % % % % ")
print("") print("")
...@@ -245,7 +248,7 @@ function MainFunction( RES ) { ...@@ -245,7 +248,7 @@ function MainFunction( RES ) {
$("#category0").hide(); $("#category0").hide();
$("#category1").show(); $("#category1").show();
if($("#slidercat1nodesweight").html()=="") if($("#slidercat1nodesweight").html()=="")
NodeWeightFilter( this.categories , "#slidercat1nodesweight" , this.categories[1], "type" ,"size"); NodeWeightFilter( this.categories , "#slidercat1nodesweight" , this.categories[1], "type" ,"size");
if($("#slidercat1edgesweight").html()=="") if($("#slidercat1edgesweight").html()=="")
...@@ -263,7 +266,7 @@ function MainFunction( RES ) { ...@@ -263,7 +266,7 @@ function MainFunction( RES ) {
$("#category0").show(); $("#category0").show();
$("#category1").hide(); $("#category1").hide();
if($("#slidercat0nodesweight").html()=="") if($("#slidercat0nodesweight").html()=="")
NodeWeightFilter( this.categories , "#slidercat0nodesweight" , this.categories[0], "type" ,"size"); NodeWeightFilter( this.categories , "#slidercat0nodesweight" , this.categories[0], "type" ,"size");
if($("#slidercat0edgesweight").html()=="") if($("#slidercat0edgesweight").html()=="")
...@@ -275,7 +278,7 @@ function MainFunction( RES ) { ...@@ -275,7 +278,7 @@ function MainFunction( RES ) {
} }
set_ClustersLegend ( "clust_default" ) set_ClustersLegend ( "clust_default" )
} else { } else {
//finished //finished
$("#slidercat1nodessize").freshslider({ $("#slidercat1nodessize").freshslider({
step:1, step:1,
...@@ -295,7 +298,7 @@ function MainFunction( RES ) { ...@@ -295,7 +298,7 @@ function MainFunction( RES ) {
partialGraph.draw(); partialGraph.draw();
}); });
} }
}); });
} }
...@@ -311,7 +314,7 @@ function MainFunction( RES ) { ...@@ -311,7 +314,7 @@ function MainFunction( RES ) {
} }
}).index(); }).index();
partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.8).draw(); // partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.8).draw();
// fa2enabled=true; //partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.8).draw(); // fa2enabled=true; //partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.8).draw();
// $.doTimeout(1,function(){ // $.doTimeout(1,function(){
...@@ -337,18 +340,16 @@ function MainFunction( RES ) { ...@@ -337,18 +340,16 @@ function MainFunction( RES ) {
$("footer").remove() $("footer").remove()
console.log( "FIN" ) console.log( "FIN" )
fa2enabled=true; partialGraph.startForceAtlas2(); fa2enabled=true; partialGraph.startForceAtlas2();
setTimeout(function() { setTimeout(function() {
console.log( "LALALALALALLA" ) console.log( "LALALALALALLA" )
console.log( "hello" )
partialGraph.stopForceAtlas2(); partialGraph.stopForceAtlas2();
}, fa2seconds*1000); }, fa2seconds*1000);
} }
console.log("finish") console.log("finish")
This diff is collapsed.
This diff is collapsed.
function draw1Circle(ctx , x , y , color) { function draw1Circle(ctx , x , y , color) {
console.log('FUN t.minimap:draw1Circle')
ctx.strokeStyle = '#000'; ctx.strokeStyle = '#000';
ctx.lineWidth = 1; ctx.lineWidth = 1;
ctx.fillStyle = color; ctx.fillStyle = color;
...@@ -14,6 +15,7 @@ function draw1Circle(ctx , x , y , color) { ...@@ -14,6 +15,7 @@ function draw1Circle(ctx , x , y , color) {
function trackMouse() { function trackMouse() {
console.log('FUN t.minimap:trackMouse')
if(!shift_key) { if(!shift_key) {
// $.doTimeout(300,function (){ // $.doTimeout(300,function (){
var ctx = partialGraph._core.domElements.mouse.getContext('2d'); var ctx = partialGraph._core.domElements.mouse.getContext('2d');
...@@ -22,13 +24,13 @@ function trackMouse() { ...@@ -22,13 +24,13 @@ function trackMouse() {
x = partialGraph._core.mousecaptor.mouseX; x = partialGraph._core.mousecaptor.mouseX;
y = partialGraph._core.mousecaptor.mouseY; y = partialGraph._core.mousecaptor.mouseY;
ctx.strokeStyle = '#000'; ctx.strokeStyle = '#000';
ctx.lineWidth = 1; ctx.lineWidth = 1;
ctx.fillStyle = "#71C3FF"; ctx.fillStyle = "#71C3FF";
ctx.globalAlpha = 0.5; ctx.globalAlpha = 0.5;
ctx.beginPath(); ctx.beginPath();
if(partialGraph._core.mousecaptor.ratio>showLabelsIfZoom){ if(partialGraph._core.mousecaptor.ratio>showLabelsIfZoom){
for(var i in partialGraph._core.graph.nodesIndex){ for(var i in partialGraph._core.graph.nodesIndex){
n=partialGraph._core.graph.nodesIndex[i]; n=partialGraph._core.graph.nodesIndex[i];
...@@ -63,7 +65,7 @@ function trackMouse() { ...@@ -63,7 +65,7 @@ function trackMouse() {
if(partialGraph.forceatlas2 && partialGraph.forceatlas2.count<=1) { if(partialGraph.forceatlas2 && partialGraph.forceatlas2.count<=1) {
partialGraph.draw(2,2,2); partialGraph.draw(2,2,2);
} }
} }
ctx.arc(x, y, cursor_size, 0, Math.PI * 2, true); ctx.arc(x, y, cursor_size, 0, Math.PI * 2, true);
//ctx.arc(partialGraph._core.width/2, partialGraph._core.height/2, 4, 0, 2 * Math.PI, true);/*todel*/ //ctx.arc(partialGraph._core.width/2, partialGraph._core.height/2, 4, 0, 2 * Math.PI, true);/*todel*/
ctx.closePath(); ctx.closePath();
...@@ -74,6 +76,7 @@ function trackMouse() { ...@@ -74,6 +76,7 @@ function trackMouse() {
}; };
function changeGraphPosition(evt, echelle) { function changeGraphPosition(evt, echelle) {
console.log('FUN t.minimap:changeGraphPosition')
document.body.style.cursor = "move"; document.body.style.cursor = "move";
var _coord = { var _coord = {
x : evt.pageX, x : evt.pageX,
...@@ -86,22 +89,22 @@ function changeGraphPosition(evt, echelle) { ...@@ -86,22 +89,22 @@ function changeGraphPosition(evt, echelle) {
} }
function onOverviewMove(evt) { function onOverviewMove(evt) {
console.log("onOverViewMove"); console.log('FUN t.minimap:onOverviewMove')
/* /*
pageX: 1247 pageY: 216 pageX: 1247 pageY: 216
screenX: 1188 screenY: 307 screenX: 1188 screenY: 307
pageX: 1444 pageY: 216 pageX: 1444 pageY: 216
screenX: 1365 screenY: 307 screenX: 1365 screenY: 307
*/ */
if (partialGraph.dragOn) { if (partialGraph.dragOn) {
changeGraphPosition(evt,-overviewScale); changeGraphPosition(evt,-overviewScale);
} }
} }
function startMove(evt){ function startMove(evt){
console.log("startMove"); console.log('FUN t.minimap:startMove')
evt.preventDefault(); evt.preventDefault();
partialGraph.dragOn = true; partialGraph.dragOn = true;
partialGraph.lastMouse = { partialGraph.lastMouse = {
...@@ -112,13 +115,14 @@ function startMove(evt){ ...@@ -112,13 +115,14 @@ function startMove(evt){
} }
function endMove(evt){ function endMove(evt){
console.log("endMove"); console.log('FUN t.minimap:endMove')
document.body.style.cursor = "default"; document.body.style.cursor = "default";
partialGraph.dragOn = false; partialGraph.dragOn = false;
partialGraph.mouseHasMoved = false; partialGraph.mouseHasMoved = false;
} }
function onGraphScroll(evt, delta) { function onGraphScroll(evt, delta) {
console.log('FUN t.minimap:onGraphScroll')
$("#zoomSlider").slider("value",partialGraph.position().ratio); $("#zoomSlider").slider("value",partialGraph.position().ratio);
// partialGraph.totalScroll += delta; // partialGraph.totalScroll += delta;
// if (Math.abs(partialGraph.totalScroll) >= 1) { // if (Math.abs(partialGraph.totalScroll) >= 1) {
...@@ -130,13 +134,13 @@ function onGraphScroll(evt, delta) { ...@@ -130,13 +134,13 @@ function onGraphScroll(evt, delta) {
// //_off = $(this).offset(), // //_off = $(this).offset(),
// //_deltaX = evt.pageX - _el.width() / 2 - _off.left, // //_deltaX = evt.pageX - _el.width() / 2 - _off.left,
// //_deltaY = evt.pageY - _el.height() / 2 - _off.top; // //_deltaY = evt.pageY - _el.height() / 2 - _off.top;
// var // var
// mx=evt.offsetX, // mx=evt.offsetX,
// my=evt.offsetY; // my=evt.offsetY;
// partialGraph.centreX=mx*((partialGraph._core.width-1)/(overviewWidth)), // partialGraph.centreX=mx*((partialGraph._core.width-1)/(overviewWidth)),
// partialGraph.centreY=my*((partialGraph._core.height-1)/(overviewHeight)); // partialGraph.centreY=my*((partialGraph._core.height-1)/(overviewHeight));
// // console.log("mx: "+mx+" - my: "+ my); // // console.log("mx: "+mx+" - my: "+ my);
// // console.log("cx: "+cx+" - cy: "+ cy); // // console.log("cx: "+cx+" - cy: "+ cy);
// // partialGraph.centreX =cx; // // partialGraph.centreX =cx;
// // partialGraph.centreY =cy; // // partialGraph.centreY =cy;
...@@ -155,13 +159,13 @@ function onGraphScroll(evt, delta) { ...@@ -155,13 +159,13 @@ function onGraphScroll(evt, delta) {
// //_off = $(this).offset(), // //_off = $(this).offset(),
// //_deltaX = evt.pageX - _el.width() / 2 - _off.left, // //_deltaX = evt.pageX - _el.width() / 2 - _off.left,
// //_deltaY = evt.pageY - _el.height() / 2 - _off.top; // //_deltaY = evt.pageY - _el.height() / 2 - _off.top;
// var // var
// mx=evt.offsetX, // mx=evt.offsetX,
// my=evt.offsetY; // my=evt.offsetY;
// partialGraph.centreX=mx*((partialGraph._core.width-1)/(overviewWidth)), // partialGraph.centreX=mx*((partialGraph._core.width-1)/(overviewWidth)),
// partialGraph.centreY=my*((partialGraph._core.height-1)/(overviewHeight)); // partialGraph.centreY=my*((partialGraph._core.height-1)/(overviewHeight));
// // console.log("mx: "+mx+" - my: "+ my); // // console.log("mx: "+mx+" - my: "+ my);
// // console.log("cx: "+cx+" - cy: "+ cy); // // console.log("cx: "+cx+" - cy: "+ cy);
// // partialGraph.centreX =cx; // // partialGraph.centreX =cx;
// // partialGraph.centreY =cy; // // partialGraph.centreY =cy;
...@@ -174,9 +178,10 @@ function onGraphScroll(evt, delta) { ...@@ -174,9 +178,10 @@ function onGraphScroll(evt, delta) {
} }
function initializeMap() { function initializeMap() {
console.log('FUN t.minimap:initializeMap')
clearInterval(partialGraph.timeRefresh); clearInterval(partialGraph.timeRefresh);
partialGraph.oldParams = {}; partialGraph.oldParams = {};
if(minimap){ if(minimap){
$("#overviewzone").css({ $("#overviewzone").css({
width : overviewWidth + "px", width : overviewWidth + "px",
...@@ -191,7 +196,8 @@ function initializeMap() { ...@@ -191,7 +196,8 @@ function initializeMap() {
} }
function updateMap(){ function updateMap(){
if(minimap){ console.log('FUN t.minimap:updateMap')
if(minimap){
partialGraph.imageMini=""; partialGraph.imageMini="";
partialGraph.ctxMini=""; partialGraph.ctxMini="";
partialGraph.ctxMini = document.getElementById('overview').getContext('2d'); partialGraph.ctxMini = document.getElementById('overview').getContext('2d');
...@@ -205,21 +211,22 @@ function updateMap(){ ...@@ -205,21 +211,22 @@ function updateMap(){
aleat = Math.random() * numPosibilidades; aleat = Math.random() * numPosibilidades;
partialGraph.ctxMini.arc(((n.displayX/1.2)-200)*0.25 , ((n.displayY/1.2)+110)*0.25 , (0.9 + aleat)*0.25+1 , 0 , Math.PI*2 , true); partialGraph.ctxMini.arc(((n.displayX/1.2)-200)*0.25 , ((n.displayY/1.2)+110)*0.25 , (0.9 + aleat)*0.25+1 , 0 , Math.PI*2 , true);
// //console.log(n.x*1000 +" * 0.25"+" _ "+ n.y*1000 +" * 0.25"+" _ "+ (0.9 + aleat) +" * 0.25 + 1"); // //console.log(n.x*1000 +" * 0.25"+" _ "+ n.y*1000 +" * 0.25"+" _ "+ (0.9 + aleat) +" * 0.25 + 1");
// //
partialGraph.ctxMini.closePath(); partialGraph.ctxMini.closePath();
partialGraph.ctxMini.fill(); partialGraph.ctxMini.fill();
} }
// //
}); });
partialGraph.imageMini = partialGraph.ctxMini.getImageData(0, 0, overviewWidth, overviewHeight); partialGraph.imageMini = partialGraph.ctxMini.getImageData(0, 0, overviewWidth, overviewHeight);
} }
} }
function traceMap() { function traceMap() {
console.log('FUN t.minimap:traceMap')
//pr("\ttracingmap"); //pr("\ttracingmap");
partialGraph.echelleGenerale = Math.pow( Math.SQRT2, partialGraph.position().ratio ); partialGraph.echelleGenerale = Math.pow( Math.SQRT2, partialGraph.position().ratio );
partialGraph.ctxMini.putImageData(partialGraph.imageMini, 0, 0); partialGraph.ctxMini.putImageData(partialGraph.imageMini, 0, 0);
var _r = 0.25 / partialGraph.echelleGenerale, var _r = 0.25 / partialGraph.echelleGenerale,
cx = partialGraph.centreX, cx = partialGraph.centreX,
cy = partialGraph.centreY, cy = partialGraph.centreY,
...@@ -235,11 +242,12 @@ function traceMap() { ...@@ -235,11 +242,12 @@ function traceMap() {
} }
function startMiniMap(){ function startMiniMap(){
console.log('FUN t.minimap:startMiniMap')
if(minimap){ if(minimap){
partialGraph.ctxMini = document.getElementById('overview').getContext('2d'); partialGraph.ctxMini = document.getElementById('overview').getContext('2d');
partialGraph.ctxMini.clearRect(0, 0, overviewWidth, overviewHeight); partialGraph.ctxMini.clearRect(0, 0, overviewWidth, overviewHeight);
partialGraph.totalScroll=0; partialGraph.totalScroll=0;
partialGraph.centreX = partialGraph._core.width/2; partialGraph.centreX = partialGraph._core.width/2;
partialGraph.centreY = partialGraph._core.heigth/2; partialGraph.centreY = partialGraph._core.heigth/2;
} }
} }
\ No newline at end of file
...@@ -6,6 +6,7 @@ var first_time=true; ...@@ -6,6 +6,7 @@ var first_time=true;
sigma.forceatlas2 = sigma.forceatlas2 || {}; sigma.forceatlas2 = sigma.forceatlas2 || {};
sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
console.log('FUN t.sigma.forceatlas2:ForceAtlas2')
sigma.classes.Cascade.call(this); sigma.classes.Cascade.call(this);
var self = this; var self = this;
this.graph = graph; this.graph = graph;
...@@ -149,7 +150,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -149,7 +150,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
} }
} else { } else {
if( self.firstit ) { if( self.firstit ) {
n.x = self.Ox + self.R*Math.cos(Math.PI*self.stepDeg*mult); n.x = self.Ox + self.R*Math.cos(Math.PI*self.stepDeg*mult);
n.y = self.Oy + self.R*Math.sin(Math.PI*self.stepDeg*mult); n.y = self.Oy + self.R*Math.sin(Math.PI*self.stepDeg*mult);
...@@ -158,7 +159,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -158,7 +159,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
} }
} }
}); });
self.firstit = false ; self.firstit = false ;
...@@ -274,21 +275,21 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -274,21 +275,21 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
if (self.p.edgeWeightInfluence == 0) { if (self.p.edgeWeightInfluence == 0) {
while (i < edges.length && i < self.state.index + cInt) { while (i < edges.length && i < self.state.index + cInt) {
var e = edges[i++]; var e = edges[i++];
if(!e.hidden) { if(!e.hidden) {
Attraction.apply_nn(e.source, e.target, 1); Attraction.apply_nn(e.source, e.target, 1);
} }
} }
} else if (self.p.edgeWeightInfluence == 1) { } else if (self.p.edgeWeightInfluence == 1) {
while (i < edges.length && i < self.state.index + cInt) { while (i < edges.length && i < self.state.index + cInt) {
var e = edges[i++]; var e = edges[i++];
if(!e.hidden) { if(!e.hidden) {
Attraction.apply_nn(e.source, e.target, e.weight || 1); Attraction.apply_nn(e.source, e.target, e.weight || 1);
} }
} }
} else { } else {
while (i < edges.length && i < self.state.index + cInt) { while (i < edges.length && i < self.state.index + cInt) {
var e = edges[i++]; var e = edges[i++];
if(!e.hidden) { if(!e.hidden) {
Attraction.apply_nn( Attraction.apply_nn(
e.source, e.target, e.source, e.target,
Math.pow(e.weight || 1, self.p.edgeWeightInfluence) Math.pow(e.weight || 1, self.p.edgeWeightInfluence)
...@@ -325,7 +326,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -325,7 +326,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
totalSwinging += n.fa2.mass * swinging; totalSwinging += n.fa2.mass * swinging;
swingingSum += swinging; swingingSum += swinging;
promdxdy += (Math.abs(n.fa2.dx)+Math.abs(n.fa2.dy))/2; /**/ promdxdy += (Math.abs(n.fa2.dx)+Math.abs(n.fa2.dy))/2; /**/
totalEffectiveTraction += n.fa2.mass * totalEffectiveTraction += n.fa2.mass *
0.5 * 0.5 *
Math.sqrt( Math.sqrt(
...@@ -334,16 +335,16 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -334,16 +335,16 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
); );
} }
}); });
self.p.totalSwinging = totalSwinging; self.p.totalSwinging = totalSwinging;
var convg= ((Math.pow(nodes.length,2))/promdxdy); /**/ var convg= ((Math.pow(nodes.length,2))/promdxdy); /**/
var swingingVSnodes_length = swingingSum/nodes.length; /**/ var swingingVSnodes_length = swingingSum/nodes.length; /**/
if(stopcriteria && (convg > swingingVSnodes_length)){ if(stopcriteria && (convg > swingingVSnodes_length)){
pr("i've applied the stopcriteria: "+self.count) pr("i've applied the stopcriteria: "+self.count)
partialGraph.stopForceAtlas2(); partialGraph.stopForceAtlas2();
} }
self.p.totalEffectiveTraction = totalEffectiveTraction; self.p.totalEffectiveTraction = totalEffectiveTraction;
// We want that swingingMovement < tolerance * convergenceMovement // We want that swingingMovement < tolerance * convergenceMovement
...@@ -362,7 +363,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -362,7 +363,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
// Save old coordinates // Save old coordinates
nodes.forEach(function(n) { nodes.forEach(function(n) {
if(!n.hidden && n.degree>0) { if(!n.hidden && n.degree>0) {
n.old_x = +n.x; n.old_x = +n.x;
n.old_y = +n.y; n.old_y = +n.y;
} }
...@@ -403,7 +404,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -403,7 +404,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
} }
} }
if(self.isolated>0 && self.count%50 == 0) { if(self.isolated>0 && self.count%50 == 0) {
nodes.forEach(function(n) { nodes.forEach(function(n) {
if(n.degree>0) { if(n.degree>0) {
...@@ -982,6 +983,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -982,6 +983,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
// The Region class, as used by the Barnes Hut optimization // The Region class, as used by the Barnes Hut optimization
sigma.forceatlas2.Region = function(nodes, depth) { sigma.forceatlas2.Region = function(nodes, depth) {
console.log('FUN t.sigma.forceatlas2:Region')
sigma.classes.Cascade.call(this); sigma.classes.Cascade.call(this);
this.depthLimit = 20; this.depthLimit = 20;
this.size = 0; this.size = 0;
...@@ -994,11 +996,12 @@ sigma.forceatlas2.Region = function(nodes, depth) { ...@@ -994,11 +996,12 @@ sigma.forceatlas2.Region = function(nodes, depth) {
massCenterX: 0, massCenterX: 0,
massCenterY: 0 massCenterY: 0
}; };
this.updateMassAndGeometry(); this.updateMassAndGeometry();
} }
sigma.forceatlas2.Region.prototype.updateMassAndGeometry = function() { sigma.forceatlas2.Region.prototype.updateMassAndGeometry = function() {
console.log('FUN t.sigma.forceatlas2:updateMassAndGeometry')
if (this.nodes.length > 1) { if (this.nodes.length > 1) {
// Compute Mass // Compute Mass
var mass = 0; var mass = 0;
...@@ -1034,6 +1037,7 @@ sigma.forceatlas2.Region.prototype.updateMassAndGeometry = function() { ...@@ -1034,6 +1037,7 @@ sigma.forceatlas2.Region.prototype.updateMassAndGeometry = function() {
}; };
sigma.forceatlas2.Region.prototype.buildSubRegions = function() { sigma.forceatlas2.Region.prototype.buildSubRegions = function() {
console.log('FUN t.sigma.forceatlas2:buildSubRegions')
if (this.nodes.length > 1) { if (this.nodes.length > 1) {
var leftNodes = []; var leftNodes = [];
var rightNodes = []; var rightNodes = [];
...@@ -1085,6 +1089,7 @@ sigma.forceatlas2.Region.prototype.buildSubRegions = function() { ...@@ -1085,6 +1089,7 @@ sigma.forceatlas2.Region.prototype.buildSubRegions = function() {
}; };
sigma.forceatlas2.Region.prototype.applyForce = function(n, Force, theta) { sigma.forceatlas2.Region.prototype.applyForce = function(n, Force, theta) {
console.log('FUN t.sigma.forceatlas2:applyForce')
if (this.nodes.length < 2) { if (this.nodes.length < 2) {
var regionNode = this.nodes[0]; var regionNode = this.nodes[0];
Force.apply_nn(n, regionNode); Force.apply_nn(n, regionNode);
...@@ -1109,6 +1114,7 @@ sigma.forceatlas2.Region.prototype.applyForce = function(n, Force, theta) { ...@@ -1109,6 +1114,7 @@ sigma.forceatlas2.Region.prototype.applyForce = function(n, Force, theta) {
sigma.publicPrototype.startForceAtlas2 = function() { sigma.publicPrototype.startForceAtlas2 = function() {
console.log('FUN t.sigma.forceatlas2:applyForce')
//if(!this.forceatlas2) { //if(!this.forceatlas2) {
if(fa2enabled) { if(fa2enabled) {
...@@ -1130,7 +1136,7 @@ sigma.publicPrototype.startForceAtlas2 = function() { ...@@ -1130,7 +1136,7 @@ sigma.publicPrototype.startForceAtlas2 = function() {
if(isolatedBCauseFilter==ene) { if(isolatedBCauseFilter==ene) {
partialGraph.stopForceAtlas2(); partialGraph.stopForceAtlas2();
return; return;
} }
$("#overviewzone").hide(); $("#overviewzone").hide();
...@@ -1148,11 +1154,12 @@ sigma.publicPrototype.startForceAtlas2 = function() { ...@@ -1148,11 +1154,12 @@ sigma.publicPrototype.startForceAtlas2 = function() {
return; return;
} }
}); });
} }
}; };
sigma.publicPrototype.stopForceAtlas2 = function() { sigma.publicPrototype.stopForceAtlas2 = function() {
console.log('FUN t.sigma.forceatlas2:stopForceAtlas2')
var present = partialGraph.states.slice(-1)[0] var present = partialGraph.states.slice(-1)[0]
if(this.forceatlas2) { if(this.forceatlas2) {
if(this.forceatlas2.count) { if(this.forceatlas2.count) {
......
This diff is collapsed.
...@@ -2,16 +2,18 @@ ...@@ -2,16 +2,18 @@
SigmaUtils = function () { SigmaUtils = function () {
console.log('FUN t.SigmaUtils:SigmaUtils:new')
this.nbCats = 0; this.nbCats = 0;
// input = GEXFstring // input = GEXFstring
this.FillGraph = function( initialState , catDict , nodes, edges , graph ) { this.FillGraph = function( initialState , catDict , nodes, edges , graph ) {
console.log('FUN t.SigmaUtils:SigmaUtils:FillGraph')
print("Filling the graaaaph:") print("Filling the graaaaph:")
print(catDict) print(catDict)
for(var i in nodes) { for(var i in nodes) {
var n = nodes[i]; var n = nodes[i];
if(initialState[catDict[n.type]]) { if(initialState[catDict[n.type]]) {
var node = ({ var node = ({
id : n.id, id : n.id,
...@@ -24,7 +26,7 @@ SigmaUtils = function () { ...@@ -24,7 +26,7 @@ SigmaUtils = function () {
}) })
if(n.shape) node.shape = n.shape; if(n.shape) node.shape = n.shape;
// console.log(node) // console.log(node)
if(Number(n.id)==287) console.log("coordinates of node 287: ( "+n.x+" , "+n.y+" ) ") if(Number(n.id)==287) console.log("coordinates of node 287: ( "+n.x+" , "+n.y+" ) ")
graph.addNode( n.id , node); graph.addNode( n.id , node);
updateSearchLabels( n.id , n.label , n.type); updateSearchLabels( n.id , n.label , n.type);
...@@ -64,11 +66,12 @@ SigmaUtils = function () { ...@@ -64,11 +66,12 @@ SigmaUtils = function () {
//for socialgraph //for socialgraph
function showMeSomeLabels(N){ function showMeSomeLabels(N){
console.log('FUN t.sigmaUtils:showMeSomeLabels')
/*======= Show some labels at the beginning =======*/ /*======= Show some labels at the beginning =======*/
minIn=50, minIn=50,
maxIn=0, maxIn=0,
minOut=50, minOut=50,
maxOut=0; maxOut=0;
partialGraph.iterNodes(function(n){ partialGraph.iterNodes(function(n){
if(n.hidden==false){ if(n.hidden==false){
if(parseInt(n.inDegree) < minIn) minIn= n.inDegree; if(parseInt(n.inDegree) < minIn) minIn= n.inDegree;
...@@ -105,28 +108,34 @@ function showMeSomeLabels(N){ ...@@ -105,28 +108,34 @@ function showMeSomeLabels(N){
} }
function getnodes(){ function getnodes(){
console.log('FUN t.sigmaUtils:getnodes')
return partialGraph._core.graph.nodes; return partialGraph._core.graph.nodes;
} }
function getnodesIndex(){ function getnodesIndex(){
console.log('FUN t.sigmaUtils:getnodesIndex')
return partialGraph._core.graph.nodesIndex; return partialGraph._core.graph.nodesIndex;
} }
function getedges(){ function getedges(){
console.log('FUN t.sigmaUtils:getedges')
return partialGraph._core.graph.edges; return partialGraph._core.graph.edges;
} }
function getedgesIndex(){ function getedgesIndex(){
console.log('FUN t.sigmaUtils:getedgesIndex')
return partialGraph._core.graph.edgesIndex; return partialGraph._core.graph.edgesIndex;
} }
function getVisibleEdges() { function getVisibleEdges() {
console.log('FUN t.sigmaUtils:getVisibleEdges')
return partialGraph._core.graph.edges.filter(function(e) { return partialGraph._core.graph.edges.filter(function(e) {
return !e['hidden']; return !e['hidden'];
}); });
} }
function getVisibleNodes() { function getVisibleNodes() {
console.log('FUN t.sigmaUtils:getVisibleNodes')
return partialGraph._core.graph.nodes.filter(function(n) { return partialGraph._core.graph.nodes.filter(function(n) {
return !n['hidden']; return !n['hidden'];
}); });
...@@ -134,21 +143,25 @@ function getVisibleNodes() { ...@@ -134,21 +143,25 @@ function getVisibleNodes() {
function getNodesByAtt(att) { function getNodesByAtt(att) {
console.log('FUN t.sigmaUtils:getNodesByAtt')
return partialGraph._core.graph.nodes.filter(function(n) { return partialGraph._core.graph.nodes.filter(function(n) {
return n['type']==att; return n['type']==att;
}); });
} }
function getn(id){ function getn(id){
console.log('FUN t.sigmaUtils:getn')
return partialGraph._core.graph.nodesIndex[id]; return partialGraph._core.graph.nodesIndex[id];
} }
function gete(id){ function gete(id){
console.log('FUN t.sigmaUtils:gete')
return partialGraph._core.graph.edgesIndex[id]; return partialGraph._core.graph.edgesIndex[id];
} }
function find(label){ function find(label){
console.log('FUN t.sigmaUtils:find')
var results=[]; var results=[];
var nds=getnodesIndex(); var nds=getnodesIndex();
label=label.toLowerCase() label=label.toLowerCase()
...@@ -158,13 +171,14 @@ function find(label){ ...@@ -158,13 +171,14 @@ function find(label){
var possiblematch=n.label.toLowerCase() var possiblematch=n.label.toLowerCase()
if (possiblematch.indexOf(label)!==-1) { if (possiblematch.indexOf(label)!==-1) {
results.push(n); results.push(n);
} }
} }
} }
return results; return results;
} }
function exactfind(label) { function exactfind(label) {
console.log('FUN t.sigmaUtils:exactfind')
nds=getnodesIndex(); nds=getnodesIndex();
for(var i in nds){ for(var i in nds){
n=nds[i]; n=nds[i];
...@@ -179,6 +193,7 @@ function exactfind(label) { ...@@ -179,6 +193,7 @@ function exactfind(label) {
function getNodeLabels(elems){ function getNodeLabels(elems){
console.log('FUN t.sigmaUtils:getNodeLabels')
var labelss=[] var labelss=[]
for(var i in elems){ for(var i in elems){
var id=(!isUndef(elems[i].key))?elems[i].key:i var id=(!isUndef(elems[i].key))?elems[i].key:i
...@@ -188,11 +203,13 @@ function getNodeLabels(elems){ ...@@ -188,11 +203,13 @@ function getNodeLabels(elems){
} }
function getNodeIDs(elems){ function getNodeIDs(elems){
console.log('FUN t.sigmaUtils:getNodeIDs')
return Object.keys(elems) return Object.keys(elems)
} }
function getSelections(){ function getSelections(){
console.log('FUN t.sigmaUtils:getSelections')
params=[]; params=[];
for(var i in selections){ for(var i in selections){
params.push(Nodes[i].label); params.push(Nodes[i].label);
...@@ -203,7 +220,8 @@ function getSelections(){ ...@@ -203,7 +220,8 @@ function getSelections(){
//This receives an array not a dict! //This receives an array not a dict!
// i added an excpt... why // i added an excpt... why
function getNeighs(sels,arr) { function getNeighs(sels,arr) {
console.log('FUN t.sigmaUtils:getNeighs')
neighDict={}; neighDict={};
for(var i in sels) { for(var i in sels) {
id = sels[i] id = sels[i]
...@@ -214,14 +232,15 @@ function getNeighs(sels,arr) { ...@@ -214,14 +232,15 @@ function getNeighs(sels,arr) {
} }
neighDict[id]=1; neighDict[id]=1;
} }
} }
return Object.keys(neighDict); return Object.keys(neighDict);
}//It returns an array not a dict! }//It returns an array not a dict!
//Using bipartiteN2D or bipartiteD2N //Using bipartiteN2D or bipartiteD2N
//This receives an array not a dict! //This receives an array not a dict!
function getNeighs2(sels,arr){ function getNeighs2(sels,arr){
console.log('FUN t.sigmaUtils:getNeighs2')
neighDict={}; neighDict={};
for(var i in sels) { for(var i in sels) {
id = sels[i] id = sels[i]
...@@ -232,12 +251,13 @@ function getNeighs2(sels,arr){ ...@@ -232,12 +251,13 @@ function getNeighs2(sels,arr){
} }
// neighDict[id]=1; // neighDict[id]=1;
} }
} }
return Object.keys(neighDict); return Object.keys(neighDict);
}//It returns an array not a dict! }//It returns an array not a dict!
//to general utils //to general utils
function getArrSubkeys(arr,id) { function getArrSubkeys(arr,id) {
console.log('FUN t.sigmaUtils:getArrSubkeys')
var result = [] var result = []
for(var i in arr) { for(var i in arr) {
result.push(arr[i][id]) result.push(arr[i][id])
...@@ -246,8 +266,9 @@ function getArrSubkeys(arr,id) { ...@@ -246,8 +266,9 @@ function getArrSubkeys(arr,id) {
} }
function getCountries(){ function getCountries(){
console.log('FUN t.sigmaUtils:getCountries')
var nodes = getVisibleNodes(); var nodes = getVisibleNodes();
var countries = {} var countries = {}
pr("in getCountries") pr("in getCountries")
for(var i in nodes) { for(var i in nodes) {
...@@ -264,6 +285,7 @@ function getCountries(){ ...@@ -264,6 +285,7 @@ function getCountries(){
function getAcronyms() { function getAcronyms() {
console.log('FUN t.sigmaUtils:getAcronyms')
var nodes = getVisibleNodes(); var nodes = getVisibleNodes();
var acrs = {} var acrs = {}
pr("in getAcronyms") pr("in getAcronyms")
...@@ -280,7 +302,7 @@ function getAcronyms() { ...@@ -280,7 +302,7 @@ function getAcronyms() {
function clustersBy(daclass , att2change ) { function clustersBy(daclass , att2change ) {
console.log('FUN t.sigmaUtils:clustersBy')
cancelSelection(false); cancelSelection(false);
var v_nodes = getVisibleNodes(); var v_nodes = getVisibleNodes();
...@@ -400,7 +422,7 @@ function clustersBy(daclass , att2change ) { ...@@ -400,7 +422,7 @@ function clustersBy(daclass , att2change ) {
function colorsBy(daclass, att2change ) { function colorsBy(daclass, att2change ) {
console.log('FUN t.sigmaUtils:colorsBy')
pr("") pr("")
pr(" = = = = = = = = = = = = = = = = = ") pr(" = = = = = = = = = = = = = = = = = ")
pr(" = = = = = = = = = = = = = = = = = ") pr(" = = = = = = = = = = = = = = = = = ")
...@@ -449,7 +471,8 @@ function colorsBy(daclass, att2change ) { ...@@ -449,7 +471,8 @@ function colorsBy(daclass, att2change ) {
//just for fun //just for fun
function makeEdgeWeightUndef() { function makeEdgeWeightUndef() {
console.log('FUN t.sigmaUtils:makeEdgeWeightUndef')
for(var e in partialGraph._core.graph.edges) { for(var e in partialGraph._core.graph.edges) {
partialGraph._core.graph.edges[e].weight=1; partialGraph._core.graph.edges[e].weight=1;
} }
} }
\ 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