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
// }
......@@ -3,11 +3,13 @@
*/
function newPopup(url) {
console.log('FUN extras_explorerjs:newPopup')
popupWindow = window.open(url,'popUpWindow','height=700,width=800,left=10,top=10,resizable=yes,scrollbars=yes,toolbar=no,menubar=no,location=no,directories=no,status=no')
}
function getIDFromURL( item ) {
console.log('FUN extras_explorerjs:getIDFromURL')
var pageurl = window.location.href.split("/")
var cid;
for(var i in pageurl) {
......@@ -20,6 +22,7 @@ function getIDFromURL( item ) {
}
function modify_ngrams( classname ) {
console.log('FUN extras_explorerjs:modify_ngrams')
console.clear()
var corpus_id = getIDFromURL( "corpora" ) // not used
......@@ -54,6 +57,7 @@ function modify_ngrams( classname ) {
}
function CRUD( parent_id , action , nodes , args , http_method , callback) {
console.log('FUN extras_explorerjs:CRUD')
var the_url = window.location.origin+"/api/node/"+parent_id+"/ngrams"+action+"/"+nodes.join("+");
the_url = the_url.replace(/\/$/, ""); //remove trailing slash
console.log( the_url )
......@@ -87,6 +91,7 @@ function CRUD( parent_id , action , nodes , args , http_method , callback) {
// then, add the button in the html with the sigmaUtils.clustersBy(x) listener.
//TODO: move to ClustersPlugin.js or smntng
function ChangeGraphAppearanceByAtt( manualflag ) {
console.log('FUN extras_explorerjs:ChangeGraphAppearanceByAtt')
if ( !isUndef(manualflag) && !colorByAtt ) colorByAtt = manualflag;
if(!colorByAtt) return;
......@@ -225,6 +230,7 @@ function CRUD( parent_id , action , nodes , args , http_method , callback) {
// then, it runs external library jLouvain()
//TODO: move to ClustersPlugin.js or smntng
function RunLouvain() {
console.log('FUN extras_explorerjs:RunLouvain')
var node_realdata = []
var nodesV = getVisibleNodes()
......@@ -251,6 +257,7 @@ function CRUD( parent_id , action , nodes , args , http_method , callback) {
// Highlight nodes belonging to cluster_i when you click in thecluster_i of the legend
//TODO: move to ClustersPlugin.js or smntng
function HoverCluster( ClusterCode ) {
console.log('FUN extras_explorerjs:HoverCluster')
console.log( ClusterCode )
var raw = ClusterCode.split("||")
......@@ -338,6 +345,7 @@ function CRUD( parent_id , action , nodes , args , http_method , callback) {
// daclass = "clust_default" | "clust_louvain" | "clust_x" ...
//TODO: move to ClustersPlugin.js or smntng
function set_ClustersLegend ( daclass ) {
console.log('FUN extras_explorerjs:set_ClustersLegend')
//partialGraph.states.slice(-1)[0].LouvainFait = true
if( daclass=="clust_default" && Clusters.length==0)
......@@ -399,6 +407,7 @@ function CRUD( parent_id , action , nodes , args , http_method , callback) {
// PHP-mode when you've a cortext db.
function getTopPapers_OriginalVersion(type){
console.log('FUN extras_explorerjs:getTopPapers_OriginalVersion')
if(getAdditionalInfo){
jsonparams=JSON.stringify(getSelections());
bi=(Object.keys(categories).length==2)?1:0;
......@@ -430,7 +439,7 @@ function getTopPapers_OriginalVersion(type){
// PHP-mode when you've a cortext db.
function getTopProposals(type , jsonparams , thisgexf) {
console.log('FUN extras_explorerjs:getTopProposals')
type = "semantic";
if(swclickActual=="social") {
nodesA = []
......@@ -486,6 +495,7 @@ function getTopProposals(type , jsonparams , thisgexf) {
// Just for Garg
function genericGetTopPapers(theids , corpus_id , thediv) {
console.log('FUN extras_explorerjs:genericGetTopPapers')
if(getAdditionalInfo) {
$("#"+thediv).show();
$.ajax({
......@@ -546,6 +556,7 @@ function genericGetTopPapers(theids , corpus_id , thediv) {
// Just for Garg: woops, override
function getTopPapers(type){
console.log('FUN extras_explorerjs:getTopPapers')
if(getAdditionalInfo){
$("#topPapers").show();
......@@ -645,6 +656,7 @@ function getTopPapers(type){
}
function getCookie(name) {
console.log('FUN extras_explorerjs:getCookie')
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
......@@ -661,6 +673,7 @@ function getCookie(name) {
}
// Just for Garg
function printCorpuses() {
console.log('FUN extras_explorerjs:printCorpuses')
console.clear()
console.log( "!!!!!!!! in printCorpuses() !!!!!!!! " )
pr(corpusesList)
......@@ -782,6 +795,7 @@ function printCorpuses() {
// Just for Garg
function GetUserPortfolio() {
console.log('FUN extras_explorerjs:GetUserPortfolio')
//http://localhost:8000/api/corpusintersection/1a50317a50145
var pageurl = window.location.href.split("/")
var pid;
......@@ -865,6 +879,7 @@ function GetUserPortfolio() {
}
function camaraButton(){
console.log('FUN extras_explorerjs:camaraButton')
$("#PhotoGraph").click(function (){
//canvas=partialGraph._core.domElements.nodes;
......@@ -917,6 +932,7 @@ function camaraButton(){
}
function getTips(){
console.log('FUN extras_explorerjs:getTips')
param='';
text =
......
......@@ -2,6 +2,8 @@
* Customize as you want ;)
*/
console.log('FUN settings_explorerjs:main')
// ============ < DEVELOPER OPTIONS > ============
var geomap=false;
var colorByAtt = false;
......@@ -268,4 +270,3 @@ var RVUniformC = function(seed){
};
}
//unifCont = new RVUniformC(100000000)
function scanDataFolder(){
console.log('FUN t.DataScanner:scanDataFolder')
$.ajax({
type: 'GET',
url: 'php/DirScan_main.php',
......@@ -17,16 +18,19 @@ function scanDataFolder(){
}
function getGexfPath(v){
console.log('FUN t.DataScanner:getGexfPath')
gexfpath=(gexfDictReverse[v])?gexfDictReverse[v]:v;
return gexfpath;
}
function getGexfLegend(gexfPath){
console.log('FUN t.DataScanner:getGexfLegend')
legend=(gexfDict[gexfPath])?gexfDict[gexfPath]:gexfPath;
return legend;
}
function jsActionOnGexfSelector(gexfLegend){
console.log('FUN t.DataScanner:jsActionOnGexfSelector')
if(getGexfPath[gexfLegend])
window.location=window.location.origin+window.location.pathname+"?file="+encodeURIComponent(getGexfPath(gexfLegend));
else
......@@ -34,6 +38,7 @@ function jsActionOnGexfSelector(gexfLegend){
}
function listGexfs(){
console.log('FUN t.DataScanner:listGexfs')
divlen=$("#gexfs").length;
if(divlen>0) {
param = JSON.stringify(gexfDict);
......
// Function.prototype.index
(function(reComments, reParams, reNames) {
Function.prototype.index = function(arrParamNames) {
console.log('FUN t.TinawebJS:Function=>index')
var fnMe = this;
arrParamNames = arrParamNames
|| (((fnMe + '').replace(reComments, '')
......@@ -22,6 +23,7 @@
);
$.fn.visibleHeight = function() {
console.log('FUN t.TinawebJS:visibleHeight')
var elBottom, elTop, scrollBot, scrollTop, visibleBottom, visibleTop;
scrollTop = $(window).scrollTop();
scrollBot = scrollTop + $(window).height();
......@@ -34,6 +36,7 @@ $.fn.visibleHeight = function() {
// for new SigmaUtils
function sigmaLimits( sigmacanvas ) {
console.log('FUN t.TinawebJS:sigmaLimits')
pw=$( sigmacanvas ).width();
ph=$( sigmacanvas ).height();
// $("body").css("padding-top",0)
......@@ -59,8 +62,10 @@ function sigmaLimits( sigmacanvas ) {
SelectionEngine = function() {
console.log('FUN t.TinawebJS:SelectionEngine:new')
// Selection Engine!! finally...
this.SelectorEngine_part01 = (function(cursorsize, area ) {
console.log('FUN t.TinawebJS:SelectionEngine:SelectorEngine_part01')
var clickedNodes = []
if(cursorsize>0) {
clickedNodes = this.SelectThis2( area )
......@@ -75,7 +80,7 @@ SelectionEngine = function() {
}).index();
this.SelectorEngine_part02 = (function( addvalue , clicktype , prevsels , currsels ) {
console.log('FUN t.TinawebJS:SelectionEngine:SelectorEngine_part02')
print("Add[]:")
print(addvalue)
print("clicktype:")
......@@ -132,6 +137,7 @@ SelectionEngine = function() {
}).index();
this.SelectorEngine = (function( cursorsize , area , addvalue , clicktype , prevsels , currsels ) {
console.log('FUN t.TinawebJS:SelectionEngine:SelectorEngine')
var targeted = []
var buffer = Object.keys(prevsels).map(Number).sort(this.sortNumber);
......@@ -203,6 +209,7 @@ SelectionEngine = function() {
// uses: SelectorEngine() and MultipleSelection2()
this.search = function(string) {
console.log('FUN t.TinawebJS:SelectionEngine:search')
var id_node = '';
var results = find(string)
......@@ -233,6 +240,7 @@ SelectionEngine = function() {
//Util
this.intersect_safe = function(a, b) {
console.log('FUN t.TinawebJS:SelectionEngine:intersect_safe')
var ai=0, bi=0;
var result = new Array();
......@@ -251,6 +259,7 @@ SelectionEngine = function() {
// return Nodes-ids under the clicked Area
// external usage : partialGraph
this.SelectThis2 = function( area ) {
console.log('FUN t.TinawebJS:SelectionEngine:SelectThis2')
var x1 = area.x1;
var y1 = area.y1;
......@@ -274,8 +283,8 @@ SelectionEngine = function() {
// external usage : partialGraph , updateLeftPanel_fix();
this.MultipleSelection2 = (function(nodes,nodesDict,edgesDict) {
pr("IN SelectionEngine.MultipleSelection2:")
console.log('FUN t.TinawebJS:SelectionEngine:MultipleSelection2')
// pr("IN SelectionEngine.MultipleSelection2:")
print(nodes)
greyEverything();
......@@ -371,6 +380,7 @@ SelectionEngine = function() {
};
TinaWebJS = function ( sigmacanvas ) {
console.log('FUN t.TinawebJS:TinaWebJS:new')
this.sigmacanvas = sigmacanvas;
this.init = function () {
......@@ -378,10 +388,12 @@ TinaWebJS = function ( sigmacanvas ) {
}
this.getSigmaCanvas = function () {
console.log('FUN t.TinawebJS:getSigmaCanvas')
return this.sigmacanvas;
}
this.AdjustSigmaCanvas = function ( sigmacanvas ) {
console.log('FUN t.TinawebJS:AdjustSigmaCanvas')
var canvasdiv = "";
if( sigmacanvas ) canvasdiv = sigmacanvas;
else canvasdiv = this.sigmacanvas;
......@@ -390,7 +402,7 @@ TinaWebJS = function ( sigmacanvas ) {
}
this.SearchListeners = function () {
console.log('FUN t.TinawebJS:SearchListeners')
var SelInst = new SelectionEngine();
$.ui.autocomplete.prototype._renderItem = function(ul, item) {
......@@ -511,7 +523,7 @@ TinaWebJS = function ( sigmacanvas ) {
// external usage: SelectorEngine*() , MultipleSelection2() ,
// enviroment.js:changeType()|changeLevel()|NodeWeightFilter()|EdgeWeightFilter
this.initListeners = function (categories, partialGraph) {
console.log('FUN t.TinawebJS:initListeners')
var SelInst = new SelectionEngine();
$("#semLoader").hide();
......@@ -809,4 +821,3 @@ TinaWebJS = function ( sigmacanvas ) {
}
};
// Mathieu Jacomy @ Sciences Po Médialab & WebAtlas
var ForceAtlas2 = function(graph) {
console.log('FUN t.asyncFA2:ForceAtlas2')
var self = this;
this.graph = graph;
......@@ -31,6 +32,7 @@ var ForceAtlas2 = function(graph) {
// Runtime (the ForceAtlas2 itself)
this.init = function() {
console.log('FUN t.asyncFA2:init')
self.state = {step: 0, index: 0};
self.graph.nodes.forEach(function(n) {
n.fa2 = {
......@@ -46,10 +48,12 @@ var ForceAtlas2 = function(graph) {
}
this.go = function() {
console.log('FUN t.asyncFA2:go')
while (self.onebucle()) {}
}
this.onebucle = function() {
console.log('FUN t.asyncFA2:onebucle')
var graph = self.graph;
var nodes = graph.nodes;
var edges = graph.edges;
......@@ -346,6 +350,7 @@ var ForceAtlas2 = function(graph) {
}
this.end = function() {
console.log('FUN t.asyncFA2:end')
this.graph.nodes.forEach(function(n) {
n.fa2 = null;
});
......@@ -353,6 +358,7 @@ var ForceAtlas2 = function(graph) {
// Auto Settings
this.setAutoSettings = function() {
console.log('FUN t.asyncFA2:setAutoSettings')
var graph = this.graph;
// Tuning
......@@ -833,6 +839,7 @@ var ForceAtlas2 = function(graph) {
var updateMassAndGeometry = function() {
console.log('FUN t.asyncFA2:updateMassAndGeometry')
if (this.nodes.length > 1) {
// Compute Mass
var mass = 0;
......@@ -885,6 +892,7 @@ var Region = function(nodes, depth) {
var buildSubRegions = function() {
console.log('FUN t.asyncFA2:buildSubRegions')
if (this.nodes.length > 1) {
var leftNodes = [];
var rightNodes = [];
......@@ -936,6 +944,7 @@ var buildSubRegions = function() {
};
var applyForce = function(n, Force, theta) {
console.log('FUN t.asyncFA2:applyForce')
if (this.nodes.length < 2) {
var regionNode = this.nodes[0];
Force.apply_nn(n, regionNode);
......@@ -958,6 +967,7 @@ var applyForce = function(n, Force, theta) {
};
var startForceAtlas2 = function(graph,limit_it) {
console.log('FUN t.asyncFA2:startForceAtlas2')
// pr("inside FA2")
//// if(!this.forceatlas2) {
// pr(graph);
......
......@@ -3,6 +3,7 @@
//============================ < NEW BUTTONS > =============================//
function changeType_old() {
console.log('FUN t.enviroment:changeType_old')
pr("***swclickActual:"+swclickActual+" , swMacro:"+swMacro);
if(swclickActual=="social") {
......@@ -118,6 +119,7 @@ function changeType_old() {
function changeType() {
console.log('FUN t.enviroment:changeType')
var present = partialGraph.states.slice(-1)[0]; // Last
var past = partialGraph.states.slice(-2)[0] // avant Last
var lastpos = partialGraph.states.length-1;
......@@ -375,6 +377,7 @@ function changeType() {
}
function changeLevel() {
console.log('FUN t.enviroment:changeLevel')
var present = partialGraph.states.slice(-1)[0]; // Last
var past = partialGraph.states.slice(-2)[0] // avant Last
var lastpos = partialGraph.states.length-1;
......@@ -501,6 +504,7 @@ function changeLevel() {
}
function changeLevel_old() {
console.log('FUN t.enviroment:changeLevel_old')
bf=swclickActual
pushSWClick(swclickActual);
pr("swMacro: "+swMacro+" - [swclickPrev: "+bf+"] - [swclickActual: "+swclickActual+"]")
......@@ -549,6 +553,7 @@ function changeLevel_old() {
// EdgeWeightFilter("#sliderAEdgeWeight", "label" , "nodes1", "weight");
// EdgeWeightFilter("#sliderBEdgeWeight", "label" , "nodes2", "weight");
function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) {
console.log('FUN t.enviroment:EdgeWeightFilter')
// console.log("")
// console.log("")
// console.log(" - - - - EdgeWeightFilter - - - ")
......@@ -760,6 +765,7 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) {
// NodeWeightFilter ( "#sliderANodeWeight" , "Document" , "type" , "size")
// NodeWeightFilter ( "#sliderBNodeWeight" , "NGram" , "type" , "size")
function NodeWeightFilter( categories , sliderDivID , type_attrb , type , criteria) {
console.log('FUN t.enviroment:NodeWeightFilter')
// if ($(sliderDivID).html()!="") {
// pr("\t\t\t\t\t\t[[ algorithm not applied "+sliderDivID+" ]]")
......@@ -873,6 +879,7 @@ function NodeWeightFilter( categories , sliderDivID , type_attrb , type , crit
}
function getGraphElement(elem) {
console.log('FUN t.enviroment:getGraphElement')
if(elem.split(";").length==1) return partialGraph._core.graph.nodesIndex[elem];
else {
if(!isUndef(partialGraph._core.graph.edgesIndex[elem]))
......@@ -889,6 +896,7 @@ function getGraphElement(elem) {
// AlgorithmForSliders ( partialGraph._core.graph.nodes , "type" , "Document" , "size")
// AlgorithmForSliders ( partialGraph._core.graph.nodes , "type" , "NGram" , "size")
function AlgorithmForSliders( elements , type_attrb , type , criteria) {
console.log('FUN t.enviroment:AlgorithmForSliders')
// console.clear()
// console.log( "\t - - - - - AlgorithmForSliders - - - - -" )
// console.log( "" )
......@@ -995,6 +1003,7 @@ function AlgorithmForSliders( elements , type_attrb , type , criteria) {
//============================= < SEARCH > =============================//
function updateSearchLabels(id,name,type){
console.log('FUN t.enviroment:updateSearchLabels')
labels.push({
'id' : id,
'label' : name,
......@@ -1003,6 +1012,7 @@ function updateSearchLabels(id,name,type){
}
function extractContext(string, context) {
console.log('FUN t.enviroment:extractContext')
var matched = string.toLowerCase().indexOf(context.toLowerCase());
if (matched == -1)
......@@ -1033,6 +1043,7 @@ function extractContext(string, context) {
}
function searchLabel(string){
console.log('FUN t.enviroment:searchLabel')
var id_node = '';
var n;
......
......@@ -10,6 +10,7 @@ function print(msg) {
//to general utils
function getClientTime(){
console.log('FUN t.globalUtils:getClientTime')
var totalSec = new Date().getTime() / 1000;
var d = new Date();
var hours = d.getHours();
......@@ -20,11 +21,13 @@ function getClientTime(){
}
function compareNumbers(a, b) {
console.log('FUN t.globalUtils:compareNumbers')
return a - b;
}
//python range(a,b) | range(a)
function calc_range(begin, end) {
console.log('FUN t.globalUtils:calc_range')
if (typeof end === "undefined") {
end = begin; begin = 0;
}
......@@ -38,6 +41,7 @@ function calc_range(begin, end) {
//to general utils (not used btw)
function cloneObject(source) {
console.log('FUN t.globalUtils:cloneObject')
for (i in source) {
if (typeof source[i] == 'source') {
this[i] = new cloneObject(source[i]);
......@@ -49,12 +53,14 @@ function cloneObject(source) {
}
function isUndef(variable){
// console.log('FUN t.globalUtils:isUndef')
if(typeof(variable)==="undefined") return true;
else return false;
}
$.fn.toggleClick = function(){
console.log('FUN t.globalUtils:toggleClick')
methods = arguments, // store the passed arguments for future reference
count = methods.length; // cache the number of methods
......@@ -71,6 +77,7 @@ $.fn.toggleClick = function(){
getUrlParam = (function () {
console.log('FUN t.globalUtils:getUrlParam')
var get = {
push:function (key,value){
var cur = this[key];
......@@ -101,6 +108,7 @@ getUrlParam = (function () {
function ArraySortByValue(array, sortFunc){
console.log('FUN t.globalUtils:ArraySortByValue')
var tmp = [];
oposMAX=0;
for (var k in array) {
......@@ -122,6 +130,7 @@ function ArraySortByValue(array, sortFunc){
function ArraySortByKey(array, sortFunc){
console.log('FUN t.globalUtils:ArraySortByKey')
var tmp = [];
for (var k in array) {
if (array.hasOwnProperty(k)) {
......@@ -140,6 +149,7 @@ function ArraySortByKey(array, sortFunc){
function is_empty(obj) {
console.log('FUN t.globalUtils:is_empty')
// Assume if it has a length property with a non-zero value
// that that property is correct.
if (obj.length && obj.length > 0) return false;
......@@ -153,12 +163,14 @@ function is_empty(obj) {
function getByID(elem) {
console.log('FUN t.globalUtils:getByID')
return document.getElementById(elem);
}
function hex2rga(sent_hex) {
// console.log('FUN t.globalUtils:hex2rga')
result = []
hex = ( sent_hex.charAt(0) === "#" ? sent_hex.substr(1) : sent_hex );
// check if 6 letters are provided
......@@ -173,6 +185,7 @@ function hex2rga(sent_hex) {
}
function calculateFull(hex) {
// console.log('FUN t.globalUtils:calculateFull')
var r = parseInt(hex.substring(0, 2), 16);
var g = parseInt(hex.substring(2, 4), 16);
var b = parseInt(hex.substring(4, 6), 16);
......@@ -182,6 +195,7 @@ function calculateFull(hex) {
// function for calculating 3 letters hex value
function calculatePartial(hex) {
console.log('FUN t.globalUtils:calculatePartial')
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 b = parseInt(hex.substring(2, 3) + hex.substring(2, 3), 16);
......@@ -189,11 +203,13 @@ function calculatePartial(hex) {
}
function componentToHex(c) {
console.log('FUN t.globalUtils:componentToHex')
var hex = c.toString(16);
return hex.length == 1 ? "0" + hex : hex;
}
function rgbToHex(r, g, b) {
console.log('FUN t.globalUtils:rgbToHex')
return "#" + componentToHex(r) + componentToHex(g) + componentToHex(b);
}
......@@ -202,6 +218,7 @@ function rgbToHex(r, g, b) {
* function to load a given css file
*/
loadCSS = function(href) {
console.log('FUN t.globalUtils:loadCSS')
var cssLink = $("<link rel='stylesheet' type='text/css' href='"+href+"'>");
$("head").append(cssLink);
};
......@@ -210,6 +227,7 @@ function rgbToHex(r, g, b) {
* function to load a given js file
*/
loadJS = function(src) {
console.log('FUN t.globalUtils:loadJS')
var jsLink = $("<script type='text/javascript' src='"+src+"'>");
$("head").append(jsLink);
};
......@@ -8,6 +8,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
*/
(function(){
jLouvain = function(){
console.log('FUN t.jLouvain:jLouvain')
//Constants
var __PASS_MAX = -1
var __MIN = 0.0000001
......@@ -115,6 +116,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
//Core-Algorithm Related
function init_status(graph, status, part){
console.log('FUN t.jLouvain:init_status')
status['nodes_to_com'] = {};
status['total_weight'] = 0;
status['internals'] = {};
......@@ -269,6 +271,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
}
function induced_graph(partition, graph){
console.log('FUN t.jLouvain:induced_graph')
var ret = {nodes:[], edges:[], _assoc_mat: {}};
var w_prec, weight;
//add nodes from partition values
......@@ -286,6 +289,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
}
function partition_at_level(dendogram, level){
console.log('FUN t.jLouvain:partition_at_level')
var partition = clone(dendogram[0]);
for(var i = 1; i < level + 1; i++ )
Object.keys(partition).forEach(function(key,j){
......@@ -298,6 +302,7 @@ Based on https://bitbucket.org/taynaud/python-louvain/overview
function generate_dendogram(graph, part_init){
console.log('FUN t.jLouvain:generate_dendogram')
if(graph.edges.length == 0){
var part = {};
......
......@@ -86,6 +86,9 @@ $.ajax({
});
function MainFunction( RES ) {
console.log(' ------------')
console.log('FUN t.main:MainFunction')
console.log(' ------------')
if(!RES["OK"]) {
alert("error: "+RES["data"])
return false;
......@@ -311,7 +314,7 @@ function MainFunction( RES ) {
}
}).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();
// $.doTimeout(1,function(){
......@@ -342,6 +345,7 @@ function MainFunction( RES ) {
fa2enabled=true; partialGraph.startForceAtlas2();
setTimeout(function() {
console.log( "LALALALALALLA" )
console.log( "hello" )
partialGraph.stopForceAtlas2();
}, fa2seconds*1000);
......@@ -349,6 +353,3 @@ function MainFunction( RES ) {
console.log("finish")
......@@ -71,6 +71,7 @@ else {
//just CSS
function sigmaLimits(){
console.log('FUN t.main_backup:sigmaLimits')
pr("\t*** sigmaLimits()")
pw=$('#sigma-example').width();
......@@ -91,6 +92,7 @@ function sigmaLimits(){
}
function bringTheNoise(pathfile,type){
console.log('FUN t.main_backup:bringTheNoise')
$("#semLoader").hide();
......@@ -305,6 +307,7 @@ function bringTheNoise(pathfile,type){
function theListeners(){
console.log('FUN t.main_backup:theListeners')
pr("in THELISTENERS");
// leftPanel("close");
$("#closeloader").click();//modal.hide doesnt work :c
......@@ -689,6 +692,7 @@ function theListeners(){
// Social Spatialization
// Semantic Spatialization
function SigmaLayouting( URL, DATA, NAME) {
console.log('FUN t.main_backup:SigmaLayouting')
pr(URL+"?"+DATA)
return $.ajax({
type: 'GET',
......
function cancelSelection (fromTagCloud) {
console.log('FUN t.methods:cancelSelection')
pr("\t***in cancelSelection");
highlightSelectedNodes(false); //Unselect the selected ones :D
opossites = [];
......@@ -54,6 +55,7 @@ function cancelSelection (fromTagCloud) {
}
function highlightSelectedNodes(flag){
console.log('FUN t.methods:highlightSelectedNodes')
pr("\t***methods.js:highlightSelectedNodes(flag)"+flag+" selEmpty:"+is_empty(selections))
if(!is_empty(selections)){
for(var i in selections) {
......@@ -76,6 +78,7 @@ function highlightSelectedNodes(flag){
}
function alertCheckBox(eventCheck){
console.log('FUN t.methods:alertCheckBox')
if(!isUndef(eventCheck.checked)) checkBox=eventCheck.checked;
}
......@@ -88,7 +91,7 @@ function alertCheckBox(eventCheck){
// b : Meso-Semantic
// AaBb: Socio-Semantic
function RefreshState(newNOW){
console.log('FUN t.methods:RefreshState')
pr("\t\t\tin RefreshState newNOW:_"+newNOW+"_.")
if (newNOW!="") {
......@@ -175,6 +178,7 @@ function RefreshState(newNOW){
}
function pushSWClick(arg){
console.log('FUN t.methods:pushSWClick')
swclickPrev = swclickActual;
swclickActual = arg;
}
......@@ -182,6 +186,7 @@ function pushSWClick(arg){
//FOR UNI-PARTITE
function selectionUni(currentNode){
console.log('FUN t.methods:selectionUni')
pr("\tin selectionUni:"+currentNode.id);
if(checkBox==false && cursor_size==0) {
highlightSelectedNodes(false);
......@@ -211,6 +216,7 @@ function selectionUni(currentNode){
// it receives entire node
function selection(currentNode){
console.log('FUN t.methods:selection')
if(checkBox==false && cursor_size==0) {
highlightSelectedNodes(false);
opossites = [];
......@@ -345,6 +351,7 @@ function selection(currentNode){
}
function getOpossitesNodes(node_id, entireNode) {
console.log('FUN t.methods:getOpossitesNodes')
node="";
if(entireNode==true) node=node_id;
else node = partialGraph._core.graph.nodesIndex[node_id];
......@@ -366,6 +373,7 @@ function getOpossitesNodes(node_id, entireNode) {
// tag cloud div
function htmlfied_alternodes(elems) {
console.log('FUN t.methods:htmlfied_alternodes')
var oppositesNodes=[]
js1='onclick="graphTagCloudElem(\'';
js2="');\""
......@@ -391,12 +399,14 @@ function htmlfied_alternodes(elems) {
}
function manualForceLabel(nodeid,active) {
console.log('FUN t.methods:manualForceLabel')
// pr("manual|"+nodeid+"|"+active)
partialGraph._core.graph.nodesIndex[nodeid].active=active;
partialGraph.draw();
}
function htmlfied_samenodes(elems) {
console.log('FUN t.methods:htmlfied_samenodes')
var sameNodes=[]
js1=' onmouseover="manualForceLabel(this.id,true);" ';
js2=' onmouseout="manualForceLabel(this.id,true);" ';
......@@ -414,7 +424,7 @@ function htmlfied_samenodes(elems) {
// nodes information div
function htmlfied_nodesatts(elems){
console.log('FUN t.methods:htmlfied_nodesatts')
var socnodes=[]
var semnodes=[]
for(var i in elems) {
......@@ -462,6 +472,7 @@ function htmlfied_nodesatts(elems){
//missing: getTopPapers for both node types
//considering complete graphs case! <= maybe i should mv it
function updateLeftPanel_fix( sels , oppos ) {
console.log('FUN t.methods:updateLeftPanel_fix')
pr("updateLeftPanel() corrected version** ")
var namesDIV=''
var alterNodesDIV=''
......@@ -519,6 +530,7 @@ function updateLeftPanel_fix( sels , oppos ) {
}
function printStates() {
console.log('FUN t.methods:printStates')
pr("\t\t\t\t---------"+getClientTime()+"---------")
pr("\t\t\t\tswMacro: "+swMacro)
pr("\t\t\t\tswActual: "+swclickActual+" | swPrev: "+swclickPrev)
......@@ -534,11 +546,13 @@ function printStates() {
//true: button disabled
//false: button enabled
function LevelButtonDisable( TF ){
console.log('FUN t.methods:LevelButtonDisable')
$('#changelevel').prop('disabled', TF);
}
//Fixed! apres: refactor!
function graphTagCloudElem(nodes) {
console.log('FUN t.methods:graphTagCloudElem')
pr("in graphTagCloudElem, nodae_id: "+nodes);
cancelSelection();
partialGraph.emptyGraph();
......@@ -648,7 +662,7 @@ function graphTagCloudElem(nodes) {
function greyEverything(){
console.log('FUN t.methods:greyEverything')
nds = partialGraph._core.graph.nodes.filter(function(n) {
return !n['hidden'];
});
......@@ -689,7 +703,7 @@ function greyEverything(){
function markAsSelected_new(n_id) {
console.log('FUN t.methods:markAsSelected_new')
if(n_id.id) nodeSel=n_id;
else nodeSel = partialGraph._core.graph.nodesIndex[n_id];
......@@ -747,6 +761,7 @@ function markAsSelected_new(n_id) {
//it is a mess but it works.
// TODO: refactor this
function markAsSelected(n_id,sel) {
console.log('FUN t.methods:markAsSelected')
if(!isUndef(n_id.id)) nodeSel=n_id;
else nodeSel = partialGraph._core.graph.nodesIndex[n_id];
......@@ -1038,6 +1053,7 @@ function markAsSelected(n_id,sel) {
//to_del
function DrawAsSelectedNodes( nodeskeys ) {
console.log('FUN t.methods:DrawAsSelectedNodes')
greyEverything();
var ndsids=[]
......@@ -1063,7 +1079,7 @@ function DrawAsSelectedNodes( nodeskeys ) {
//to_del
function MultipleSelection(nodes , desalg){
console.log('FUN t.methods:MultipleSelection')
pr("IN MULTIPLE SELECTION: checkbox="+checkBox)
var prevsels = selections;
......@@ -1146,6 +1162,7 @@ function MultipleSelection(nodes , desalg){
function graphResetColor(){
console.log('FUN t.methods:graphResetColor')
nds = partialGraph._core.graph.nodes.filter(function(x) {
return !x['hidden'];
});
......@@ -1168,7 +1185,7 @@ function graphResetColor(){
//to_del
function createEdgesForExistingNodes (typeOfNodes) {
console.log('FUN t.methods:createEdgesForExistingNodes')
if(typeOfNodes=="social") typeOfNodes="Scholars"
if(typeOfNodes=="semantic") typeOfNodes="Keywords"
if(typeOfNodes=="sociosemantic") typeOfNodes="Bipartite"
......@@ -1315,6 +1332,7 @@ function createEdgesForExistingNodes (typeOfNodes) {
}
function hideEverything(){
console.log('FUN t.methods:hideEverything')
pr("\thiding all");
nodeslength=0;
for(var n in partialGraph._core.graph.nodesIndex){
......@@ -1331,7 +1349,7 @@ function hideEverything(){
function add1Elem(id) {
console.log('FUN t.methods:add1Elem')
id = ""+id;
if(id.split(";").length==1) { // i've received a NODE
id = parseInt(id)
......@@ -1381,6 +1399,7 @@ function add1Elem(id) {
//to_del
function unHide(id){
console.log('FUN t.methods:unHide')
// pr("unhide "+id)
id = ""+id;
if(id.split(";").length==1) {
......@@ -1430,6 +1449,7 @@ function unHide(id){
}
function pushFilterValue(filtername,arg){
console.log('FUN t.methods:pushFilterValue')
if(lastFilter[filtername]["orig"]=="-") {
lastFilter[filtername]["orig"] = arg;
lastFilter[filtername]["last"] = arg;
......@@ -1442,6 +1462,7 @@ function pushFilterValue(filtername,arg){
//to_del
function add1Edge(ID) {
console.log('FUN t.methods:add1Edge')
if(gete(ID)) return;
var s = Edges[ID].sourceID
var t = Edges[ID].targetID
......@@ -1472,6 +1493,7 @@ function add1Edge(ID) {
//to_del
function hideElem(id){
console.log('FUN t.methods:hideElem')
if(id.split(";").length==1){
//updateSearchLabels(id,Nodes[id].label,Nodes[id].type);
partialGraph._core.graph.nodesIndex[id].hidden=true;
......@@ -1484,6 +1506,7 @@ function hideElem(id){
//to_del
function unHideElem(id){
console.log('FUN t.methods:unHideElem')
if(id.split(";").length==1){
//updateSearchLabels(id,Nodes[id].label,Nodes[id].type);
partialGraph._core.graph.nodesIndex[id].hidden=false;
......@@ -1496,7 +1519,7 @@ function unHideElem(id){
//to_del
function changeToMeso(iwannagraph) {
console.log('FUN t.methods:changeToMeso')
labels=[]
iwantograph=iwannagraph;//just a mess
......@@ -1740,6 +1763,7 @@ function changeToMeso(iwannagraph) {
//to_del
function changeToMacro(iwannagraph) {
console.log('FUN t.methods:changeToMacro')
labels=[]
pr("CHANGING TO Macro-"+iwannagraph);
......@@ -1875,6 +1899,7 @@ function changeToMacro(iwannagraph) {
//to_del
function highlightOpossites (list){/*here*/
console.log('FUN t.methods:highlightOpossites')
for(var n in list){
if(!isUndef(partialGraph._core.graph.nodesIndex[n])){
partialGraph._core.graph.nodesIndex[n].active=true;
......@@ -1883,7 +1908,7 @@ function highlightOpossites (list){/*here*/
}
function saveGraph() {
console.log('FUN t.methods:saveGraph')
size = getByID("check_size").checked
color = getByID("check_color").checked
atts = {"size":size,"color":color}
......@@ -1900,6 +1925,7 @@ function saveGraph() {
}
function saveGEXF(nodes,edges,atts){
console.log('FUN t.methods:saveGEXF')
gexf = '<?xml version="1.0" encoding="UTF-8"?>\n';
gexf += '<gexf xmlns="http://www.gexf.net/1.1draft" xmlns:viz="http://www.gephi.org/gexf/viz" version="1.1">\n';
gexf += '<graph defaultedgetype="undirected" type="static">\n';
......@@ -1945,7 +1971,7 @@ function saveGEXF(nodes,edges,atts){
}
function saveGraphIMG(){
console.log('FUN t.methods:saveGraphIMG')
var strDownloadMime = "image/octet-stream"
var nodesDiv = partialGraph._core.domElements.nodes;
......
function draw1Circle(ctx , x , y , color) {
console.log('FUN t.minimap:draw1Circle')
ctx.strokeStyle = '#000';
ctx.lineWidth = 1;
ctx.fillStyle = color;
......@@ -14,6 +15,7 @@ function draw1Circle(ctx , x , y , color) {
function trackMouse() {
console.log('FUN t.minimap:trackMouse')
if(!shift_key) {
// $.doTimeout(300,function (){
var ctx = partialGraph._core.domElements.mouse.getContext('2d');
......@@ -74,6 +76,7 @@ function trackMouse() {
};
function changeGraphPosition(evt, echelle) {
console.log('FUN t.minimap:changeGraphPosition')
document.body.style.cursor = "move";
var _coord = {
x : evt.pageX,
......@@ -86,7 +89,7 @@ function changeGraphPosition(evt, echelle) {
}
function onOverviewMove(evt) {
console.log("onOverViewMove");
console.log('FUN t.minimap:onOverviewMove')
/*
pageX: 1247 pageY: 216
screenX: 1188 screenY: 307
......@@ -101,7 +104,7 @@ function onOverviewMove(evt) {
}
function startMove(evt){
console.log("startMove");
console.log('FUN t.minimap:startMove')
evt.preventDefault();
partialGraph.dragOn = true;
partialGraph.lastMouse = {
......@@ -112,13 +115,14 @@ function startMove(evt){
}
function endMove(evt){
console.log("endMove");
console.log('FUN t.minimap:endMove')
document.body.style.cursor = "default";
partialGraph.dragOn = false;
partialGraph.mouseHasMoved = false;
}
function onGraphScroll(evt, delta) {
console.log('FUN t.minimap:onGraphScroll')
$("#zoomSlider").slider("value",partialGraph.position().ratio);
// partialGraph.totalScroll += delta;
// if (Math.abs(partialGraph.totalScroll) >= 1) {
......@@ -174,6 +178,7 @@ function onGraphScroll(evt, delta) {
}
function initializeMap() {
console.log('FUN t.minimap:initializeMap')
clearInterval(partialGraph.timeRefresh);
partialGraph.oldParams = {};
......@@ -191,6 +196,7 @@ function initializeMap() {
}
function updateMap(){
console.log('FUN t.minimap:updateMap')
if(minimap){
partialGraph.imageMini="";
partialGraph.ctxMini="";
......@@ -216,6 +222,7 @@ function updateMap(){
}
function traceMap() {
console.log('FUN t.minimap:traceMap')
//pr("\ttracingmap");
partialGraph.echelleGenerale = Math.pow( Math.SQRT2, partialGraph.position().ratio );
partialGraph.ctxMini.putImageData(partialGraph.imageMini, 0, 0);
......@@ -235,6 +242,7 @@ function traceMap() {
}
function startMiniMap(){
console.log('FUN t.minimap:startMiniMap')
if(minimap){
partialGraph.ctxMini = document.getElementById('overview').getContext('2d');
partialGraph.ctxMini.clearRect(0, 0, overviewWidth, overviewHeight);
......
......@@ -6,6 +6,7 @@ var first_time=true;
sigma.forceatlas2 = sigma.forceatlas2 || {};
sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
console.log('FUN t.sigma.forceatlas2:ForceAtlas2')
sigma.classes.Cascade.call(this);
var self = this;
this.graph = graph;
......@@ -982,6 +983,7 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
// The Region class, as used by the Barnes Hut optimization
sigma.forceatlas2.Region = function(nodes, depth) {
console.log('FUN t.sigma.forceatlas2:Region')
sigma.classes.Cascade.call(this);
this.depthLimit = 20;
this.size = 0;
......@@ -999,6 +1001,7 @@ sigma.forceatlas2.Region = function(nodes, depth) {
}
sigma.forceatlas2.Region.prototype.updateMassAndGeometry = function() {
console.log('FUN t.sigma.forceatlas2:updateMassAndGeometry')
if (this.nodes.length > 1) {
// Compute Mass
var mass = 0;
......@@ -1034,6 +1037,7 @@ sigma.forceatlas2.Region.prototype.updateMassAndGeometry = function() {
};
sigma.forceatlas2.Region.prototype.buildSubRegions = function() {
console.log('FUN t.sigma.forceatlas2:buildSubRegions')
if (this.nodes.length > 1) {
var leftNodes = [];
var rightNodes = [];
......@@ -1085,6 +1089,7 @@ sigma.forceatlas2.Region.prototype.buildSubRegions = function() {
};
sigma.forceatlas2.Region.prototype.applyForce = function(n, Force, theta) {
console.log('FUN t.sigma.forceatlas2:applyForce')
if (this.nodes.length < 2) {
var regionNode = this.nodes[0];
Force.apply_nn(n, regionNode);
......@@ -1109,6 +1114,7 @@ sigma.forceatlas2.Region.prototype.applyForce = function(n, Force, theta) {
sigma.publicPrototype.startForceAtlas2 = function() {
console.log('FUN t.sigma.forceatlas2:applyForce')
//if(!this.forceatlas2) {
if(fa2enabled) {
......@@ -1153,6 +1159,7 @@ sigma.publicPrototype.startForceAtlas2 = function() {
};
sigma.publicPrototype.stopForceAtlas2 = function() {
console.log('FUN t.sigma.forceatlas2:stopForceAtlas2')
var present = partialGraph.states.slice(-1)[0]
if(this.forceatlas2) {
if(this.forceatlas2.count) {
......
......@@ -2,6 +2,7 @@
// Level-01
ParseCustom = function ( format , data ) {
console.log('FUN t.sigma.parseCustom:ParseCustom')
this.data = data;
this.format = format;
this.nbCats = 0;
......@@ -35,7 +36,7 @@ ParseCustom = function ( format , data ) {
// Level-02
ParseCustom.prototype.scanFile = function() {
console.log('FUN t.sigma.parseCustom:scanFile')
switch (this.format) {
case "api.json":
pr("scanFile: "+this.format)
......@@ -61,7 +62,7 @@ ParseCustom.prototype.scanFile = function() {
// Level-02
ParseCustom.prototype.makeDicts = function(categories) {
console.log('FUN t.sigma.parseCustom:makeDicts')
switch (this.format) {
case "api.json":
pr("makeDicts: "+this.format)
......@@ -90,6 +91,7 @@ ParseCustom.prototype.makeDicts = function(categories) {
// Level-00
function scanGexf(gexf) {
console.log('FUN t.sigma.parseCustom:scanGexf')
var categoriesDict={}, categories=[];
nodesNodes = gexf.getElementsByTagName('nodes');
for(i=0; i<nodesNodes.length; i++){
......@@ -138,7 +140,7 @@ function scanGexf(gexf) {
// Level-00
// for {1,2}partite graphs
function dictfyGexf( gexf , categories ) {
console.log('FUN t.sigma.parseCustom:dictfyGexf')
var catDict = {}
var catCount = {}
......@@ -474,7 +476,7 @@ function dictfyGexf( gexf , categories ) {
// Level-00
function scanJSON( data ) {
console.log('FUN t.sigma.parseCustom:scanJSON')
var categoriesDict={}, categories=[];
var nodes = data.nodes;
......@@ -516,6 +518,7 @@ function scanJSON( data ) {
// Level-00
// for {1,2}partite graphs
function dictfyJSON( data , categories ) {
console.log('FUN t.sigma.parseCustom:dictfyJSON')
console.clear()
console.log("IN DICTIFY JSON")
var catDict = {}
......@@ -717,6 +720,7 @@ function dictfyJSON( data , categories ) {
// to move
function buildInitialState( categories ) {
console.log('FUN t.sigma.parseCustom:buildInitialState')
var firstState = []
for(var i=0; i<categories.length ; i++) {
if(i==0) firstState.push(true)
......@@ -727,6 +731,7 @@ function buildInitialState( categories ) {
//to move
function makeSystemStates (cats) {
console.log('FUN t.sigma.parseCustom:makeSystemStates')
var systemstates = {}
var N=Math.pow(2 , cats.length);
......@@ -760,6 +765,7 @@ function makeSystemStates (cats) {
//to_del
function parse(gexfPath) {
console.log('FUN t.sigma.parseCustom:parse')
var gexfhttp;
gexfhttp = window.XMLHttpRequest ? new XMLHttpRequest() : new ActiveXObject('Microsoft.XMLHTTP');
gexfhttp.open('GET', gexfPath, false);
......@@ -769,6 +775,7 @@ function parse(gexfPath) {
//to_del
function scanCategories() {
console.log('FUN t.sigma.parseCustom:scanCategories')
nodesNodes = gexf.getElementsByTagName('nodes');
for(i=0; i<nodesNodes.length; i++){
var nodesNode = nodesNodes[i]; // Each xml node 'nodes' (plural)
......@@ -801,7 +808,7 @@ function scanCategories() {
//to_del
function onepartiteExtract(){
console.log('FUN t.sigma.parseCustom:onepartiteExtract')
var i, j, k;
// partialGraph.emptyGraph();
// Parse Attributes
......@@ -1045,6 +1052,7 @@ function onepartiteExtract(){
//to_del
function fullExtract(){
console.log('FUN t.sigma.parseCustom:fullExtract')
var i, j, k;
// Parse Attributes
// This is confusing, so I'll comment heavily
......@@ -1373,7 +1381,7 @@ function fullExtract(){
//to_del
function JSONFile( URL ) {
console.log('FUN t.sigma.parseCustom:JSONFile')
return $.ajax({
......@@ -1399,7 +1407,7 @@ function JSONFile( URL ) {
//to_del
function parseSimpleJSON( data , seed ) {
console.log('FUN t.sigma.parseCustom:parseSimpleJSON')
var i, j, k;
rand=new RVUniformC(seed);
//partialGraph.emptyGraph();
......@@ -1494,6 +1502,7 @@ function parseSimpleJSON( data , seed ) {
//to_del
// For CommunityExplorer API
function extractFromJson(data,seed){
console.log('FUN t.sigma.parseCustom:extractFromJson')
var i, j, k;
rand=new RVUniformC(seed);
//partialGraph.emptyGraph();
......
......@@ -2,10 +2,12 @@
SigmaUtils = function () {
console.log('FUN t.SigmaUtils:SigmaUtils:new')
this.nbCats = 0;
// input = GEXFstring
this.FillGraph = function( initialState , catDict , nodes, edges , graph ) {
console.log('FUN t.SigmaUtils:SigmaUtils:FillGraph')
print("Filling the graaaaph:")
print(catDict)
......@@ -64,6 +66,7 @@ SigmaUtils = function () {
//for socialgraph
function showMeSomeLabels(N){
console.log('FUN t.sigmaUtils:showMeSomeLabels')
/*======= Show some labels at the beginning =======*/
minIn=50,
maxIn=0,
......@@ -105,28 +108,34 @@ function showMeSomeLabels(N){
}
function getnodes(){
console.log('FUN t.sigmaUtils:getnodes')
return partialGraph._core.graph.nodes;
}
function getnodesIndex(){
console.log('FUN t.sigmaUtils:getnodesIndex')
return partialGraph._core.graph.nodesIndex;
}
function getedges(){
console.log('FUN t.sigmaUtils:getedges')
return partialGraph._core.graph.edges;
}
function getedgesIndex(){
console.log('FUN t.sigmaUtils:getedgesIndex')
return partialGraph._core.graph.edgesIndex;
}
function getVisibleEdges() {
console.log('FUN t.sigmaUtils:getVisibleEdges')
return partialGraph._core.graph.edges.filter(function(e) {
return !e['hidden'];
});
}
function getVisibleNodes() {
console.log('FUN t.sigmaUtils:getVisibleNodes')
return partialGraph._core.graph.nodes.filter(function(n) {
return !n['hidden'];
});
......@@ -134,21 +143,25 @@ function getVisibleNodes() {
function getNodesByAtt(att) {
console.log('FUN t.sigmaUtils:getNodesByAtt')
return partialGraph._core.graph.nodes.filter(function(n) {
return n['type']==att;
});
}
function getn(id){
console.log('FUN t.sigmaUtils:getn')
return partialGraph._core.graph.nodesIndex[id];
}
function gete(id){
console.log('FUN t.sigmaUtils:gete')
return partialGraph._core.graph.edgesIndex[id];
}
function find(label){
console.log('FUN t.sigmaUtils:find')
var results=[];
var nds=getnodesIndex();
label=label.toLowerCase()
......@@ -165,6 +178,7 @@ function find(label){
}
function exactfind(label) {
console.log('FUN t.sigmaUtils:exactfind')
nds=getnodesIndex();
for(var i in nds){
n=nds[i];
......@@ -179,6 +193,7 @@ function exactfind(label) {
function getNodeLabels(elems){
console.log('FUN t.sigmaUtils:getNodeLabels')
var labelss=[]
for(var i in elems){
var id=(!isUndef(elems[i].key))?elems[i].key:i
......@@ -188,11 +203,13 @@ function getNodeLabels(elems){
}
function getNodeIDs(elems){
console.log('FUN t.sigmaUtils:getNodeIDs')
return Object.keys(elems)
}
function getSelections(){
console.log('FUN t.sigmaUtils:getSelections')
params=[];
for(var i in selections){
params.push(Nodes[i].label);
......@@ -204,6 +221,7 @@ function getSelections(){
//This receives an array not a dict!
// i added an excpt... why
function getNeighs(sels,arr) {
console.log('FUN t.sigmaUtils:getNeighs')
neighDict={};
for(var i in sels) {
id = sels[i]
......@@ -222,6 +240,7 @@ function getNeighs(sels,arr) {
//Using bipartiteN2D or bipartiteD2N
//This receives an array not a dict!
function getNeighs2(sels,arr){
console.log('FUN t.sigmaUtils:getNeighs2')
neighDict={};
for(var i in sels) {
id = sels[i]
......@@ -238,6 +257,7 @@ function getNeighs2(sels,arr){
//to general utils
function getArrSubkeys(arr,id) {
console.log('FUN t.sigmaUtils:getArrSubkeys')
var result = []
for(var i in arr) {
result.push(arr[i][id])
......@@ -246,6 +266,7 @@ function getArrSubkeys(arr,id) {
}
function getCountries(){
console.log('FUN t.sigmaUtils:getCountries')
var nodes = getVisibleNodes();
var countries = {}
......@@ -264,6 +285,7 @@ function getCountries(){
function getAcronyms() {
console.log('FUN t.sigmaUtils:getAcronyms')
var nodes = getVisibleNodes();
var acrs = {}
pr("in getAcronyms")
......@@ -280,7 +302,7 @@ function getAcronyms() {
function clustersBy(daclass , att2change ) {
console.log('FUN t.sigmaUtils:clustersBy')
cancelSelection(false);
var v_nodes = getVisibleNodes();
......@@ -400,7 +422,7 @@ function clustersBy(daclass , att2change ) {
function colorsBy(daclass, att2change ) {
console.log('FUN t.sigmaUtils:colorsBy')
pr("")
pr(" = = = = = = = = = = = = = = = = = ")
pr(" = = = = = = = = = = = = = = = = = ")
......@@ -449,6 +471,7 @@ function colorsBy(daclass, att2change ) {
//just for fun
function makeEdgeWeightUndef() {
console.log('FUN t.sigmaUtils:makeEdgeWeightUndef')
for(var e in partialGraph._core.graph.edges) {
partialGraph._core.graph.edges[e].weight=1;
}
......
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