Commit d2d169a6 authored by PkSM3's avatar PkSM3

loading status for semantic-layouting OK

parent a502fd46
...@@ -247,9 +247,9 @@ var ForceAtlas2 = function(graph) { ...@@ -247,9 +247,9 @@ var ForceAtlas2 = function(graph) {
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;
......
.loader{
text-align:center;
transform: translate(0, 50%) !important;
-ms-transform: translate(0, 50%) !important; /*IE 9*/
-webkit-transform: translate(0, 50%) !important; /*Safari and Chrome */
}
.navbar { .navbar {
margin-bottom:1px; margin-bottom:1px;
} }
...@@ -15,8 +26,6 @@ ...@@ -15,8 +26,6 @@
} }
/*.btn-sm[normal] {*/ /*.btn-sm[normal] {*/
/* background-image: -webkit-linear-gradient(#5f8ab9, #3e648d 50%, #385a7f);*/ /* background-image: -webkit-linear-gradient(#5f8ab9, #3e648d 50%, #385a7f);*/
/* background-image: linear-gradient(#5f8ab9, #3e648d 50%, #385a7f);*/ /* background-image: linear-gradient(#5f8ab9, #3e648d 50%, #385a7f);*/
...@@ -32,13 +41,6 @@ ...@@ -32,13 +41,6 @@
/*.modal-vertical-centered {*/ /*.modal-vertical-centered {*/
#loader{
text-align:center;
transform: translate(0, 50%) !important;
-ms-transform: translate(0, 50%) !important; /*IE 9*/
-webkit-transform: translate(0, 50%) !important; /*Safari and Chrome */
}
#selectionsBox{ #selectionsBox{
text-align:center; text-align:center;
......
...@@ -92,7 +92,6 @@ ...@@ -92,7 +92,6 @@
<ul id="category-A" class="nav navbar-nav navbar-right"> <ul id="category-A" class="nav navbar-nav navbar-right">
<li> <li>
<ul style="list-style-type: none; margin:0em 1em;"> <ul style="list-style-type: none; margin:0em 1em;">
<li><div id="sliderANodeWeight"></div></li> <li><div id="sliderANodeWeight"></div></li>
...@@ -183,6 +182,13 @@ ...@@ -183,6 +182,13 @@
<!-- Page content --> <!-- Page content -->
<div id="sigma-example"></div> <div id="sigma-example"></div>
<div style="visibility: hidden;" id="sigma-othergraph"></div>
<img id="semLoader" style="position:absolute; top:50%; left:40%; width:80px;" src="img2/loading-bar.gif"></img>
<ul id="ctlzoom"> <ul id="ctlzoom">
<!-- <div class="content-header"> <!-- <div class="content-header">
...@@ -311,7 +317,7 @@ ...@@ -311,7 +317,7 @@
<div id="modalloader" class="modal fade"> <div id="modalloader" class="modal fade">
<div id="loader"> <div id="loader" class="loader">
<img src="img2/loader.gif"></img> <img src="img2/loader.gif"></img>
</div> </div>
<div id="closeloader" data-dismiss="modal"></div> <div id="closeloader" data-dismiss="modal"></div>
......
...@@ -50,6 +50,7 @@ var desirableScholarSize=6; //Remember that all scholars have the same size! ...@@ -50,6 +50,7 @@ var desirableScholarSize=6; //Remember that all scholars have the same size!
var stopcriteria = false; var stopcriteria = false;
var iterationsFA2=1000; var iterationsFA2=1000;
var seed=999999999;//defaultseed var seed=999999999;//defaultseed
var semanticConverged=false;
var showLabelsIfZoom=2.0; var showLabelsIfZoom=2.0;
...@@ -132,6 +133,7 @@ var overviewHover=false; ...@@ -132,6 +133,7 @@ var overviewHover=false;
var moveDelay = 80, zoomDelay = 2; var moveDelay = 80, zoomDelay = 2;
//var Vecindad; //var Vecindad;
var partialGraph; var partialGraph;
var otherGraph;
var Nodes = []; var Nodes = [];
var Edges = []; var Edges = [];
...@@ -141,8 +143,6 @@ var labels = []; ...@@ -141,8 +143,6 @@ var labels = [];
var numberOfDocs=0; var numberOfDocs=0;
var numberOfNGrams=0; var numberOfNGrams=0;
var semanticConverged=0;
var socialConverged=0;
var selections = []; var selections = [];
var deselections={}; var deselections={};
......
...@@ -8,7 +8,7 @@ function changeType() { ...@@ -8,7 +8,7 @@ function changeType() {
if(swclickActual=="social") { if(swclickActual=="social") {
if(swMacro) { if(swMacro) {
changeToMacro("semantic"); changeToMacro("semantic");
pushSWClick("semantic"); pushSWClick("semantic");
RefreshState("B") RefreshState("B")
} else { } else {
...@@ -453,21 +453,18 @@ function searchLabel(string){ ...@@ -453,21 +453,18 @@ function searchLabel(string){
function search(string) { function search(string) {
var id_node = ''; var id_node = '';
partialGraph.iterNodes(function (n) { var results = find(string)
if(!n.hidden){
if (n.label == string) { var coincd=[]
id_node = n.id; for(var i in results) {
return n; coincd.push(results[i].id)
} }
}
});
// getOpossitesNodes(id_node, false);
$.doTimeout(30,function (){ $.doTimeout(30,function (){
MultipleSelection(id_node); MultipleSelection(coincd);
$("input#searchinput").val("");
$("input#searchinput").autocomplete( "close" );
}); });
$("input#searchinput").val("");
$("input#searchinput").autocomplete( "close" );
} }
//============================ < / SEARCH > ============================// //============================ < / SEARCH > ============================//
...@@ -78,6 +78,8 @@ function sigmaLimits(){ ...@@ -78,6 +78,8 @@ function sigmaLimits(){
function bringTheNoise(pathfile,type){ function bringTheNoise(pathfile,type){
$("#semLoader").hide();
$('#modalloader').modal('show'); $('#modalloader').modal('show');
// === get width and height === // // === get width and height === //
sigmaLimits(); sigmaLimits();
...@@ -87,7 +89,12 @@ function bringTheNoise(pathfile,type){ ...@@ -87,7 +89,12 @@ function bringTheNoise(pathfile,type){
.drawingProperties(sigmaJsDrawingProperties) .drawingProperties(sigmaJsDrawingProperties)
.graphProperties(sigmaJsGraphProperties) .graphProperties(sigmaJsGraphProperties)
.mouseProperties(sigmaJsMouseProperties); .mouseProperties(sigmaJsMouseProperties);
otherGraph = sigma.init(document.getElementById('sigma-othergraph'))
// .drawingProperties(sigmaJsDrawingProperties)
// .graphProperties(sigmaJsGraphProperties)
// .mouseProperties(sigmaJsMouseProperties);
// === resize topbar and tweakbar === // // === resize topbar and tweakbar === //
var body=document.getElementsByTagName('body')[0]; var body=document.getElementsByTagName('body')[0];
...@@ -232,36 +239,6 @@ function bringTheNoise(pathfile,type){ ...@@ -232,36 +239,6 @@ function bringTheNoise(pathfile,type){
// var vis_nds = getVisibleNodes();
// pr("before_change... visible nodes:")
// for(var i in vis_nds)
// pr(vis_nds[i].id+" : "+vis_nds[i].degree)
// var vis_ndsIndex = {}
// for(var n in vis_nds) {
// id = vis_nds[n].id
// vis_ndsIndex[id] = vis_nds[n]
// vis_ndsIndex[id].degree = 0;
// }
// var vis_edgs = getVisibleEdges();
// for(var e in vis_edgs) {
// e1 = vis_edgs[e]
// n1 = e1.source.id
// n2 = e1.target.id
// vis_ndsIndex[n1]["degree"]++;
// vis_ndsIndex[n2]["degree"]++;
// }
// pr("after_change... visible nodes:")
// for(var i in vis_ndsIndex)
// pr(vis_ndsIndex[i].id+" : "+vis_ndsIndex[i].degree)
pr(getClientTime()+" : Ini FA2"); pr(getClientTime()+" : Ini FA2");
var ForceAtlas2 = new Worker("FA2.js"); var ForceAtlas2 = new Worker("FA2.js");
ForceAtlas2.postMessage({ ForceAtlas2.postMessage({
...@@ -286,7 +263,63 @@ function bringTheNoise(pathfile,type){ ...@@ -286,7 +263,63 @@ function bringTheNoise(pathfile,type){
pr("\ttotalIterations: "+iterations) pr("\ttotalIterations: "+iterations)
pr(getClientTime()+" : Fin FA2"); pr(getClientTime()+" : Fin FA2");
console.log("Parsing and FA2 complete."); console.log("Parsing and FA2 complete.");
pr("\n=================\n")
// < === ASYNCHRONOUS FA2.JS DONE!! === > // < === ASYNCHRONOUS FA2.JS DONE!! === >
pr(getClientTime()+" : Ini FA2 for SemanticGraph");
var cut1_,cut2_,iterationsFA2_=iterationsFA2;
pr(otherGraph._core.graph.nodes.length)
pr(otherGraph._core.graph.edges.length)
nbnodes = otherGraph._core.graph.nodes.length
if(nbnodes>=400 && nbnodes<1000) {
snbnodes = nbnodes+"";
cut1_ = snbnodes[0];
cut2_ = snbnodes.length;
pr("cut1 sem: "+cut1_)
pr("cut2 sem: "+cut2_)
iterationsFA2_ = Math.round(iterationsFA2/(cut1_/cut2_))
}
if(nbnodes>=1000) iterationsFA2_ = 150;
pr("iterationsFA2 sem: "+iterationsFA2_)
var ForceAtlas2_ = new Worker("FA2.js");
ForceAtlas2_.postMessage({
"nodes": otherGraph._core.graph.nodes,
"edges": otherGraph._core.graph.edges,
"it":iterationsFA2_
});
ForceAtlas2_.addEventListener('message', function(e) {
iterations=e.data.it;
nds=e.data.nodes;
for(var n in nds){
id=nds[n].id;
x=nds[n].x
y=nds[n].y
Nodes[id].x=x;
Nodes[id].y=y;
}
pr("\ttotalIterations: "+iterations)
pr(getClientTime()+" : Fin FA2 for SemanticGraph");
otherGraph.emptyGraph();
otherGraph = null;
$("#sigma-othergraph").html("");
semanticConverged = true;
$("#semLoader").hide();
if( NOW=="B" ) changeToMacro("semantic");
console.log("Parsing and FA2 complete for SemanticGraph.");
});
theListeners(); theListeners();
}); });
}, },
...@@ -414,6 +447,8 @@ function theListeners(){ ...@@ -414,6 +447,8 @@ function theListeners(){
$.ui.autocomplete.prototype._renderItem = function(ul, item) { $.ui.autocomplete.prototype._renderItem = function(ul, item) {
var searchVal = $("#searchinput").val(); var searchVal = $("#searchinput").val();
var desc = extractContext(item.desc, searchVal); var desc = extractContext(item.desc, searchVal);
pr("desc:")
pr(desc)
return $('<li onclick=\'var s = "'+item.label+'"; search(s);$("#searchinput").val(strSearchBar);\'></li>') return $('<li onclick=\'var s = "'+item.label+'"; search(s);$("#searchinput").val(strSearchBar);\'></li>')
.data('item.autocomplete', item) .data('item.autocomplete', item)
.append("<a><span class=\"labelresult\">" + item.label + "</span></a>" ) .append("<a><span class=\"labelresult\">" + item.label + "</span></a>" )
...@@ -424,7 +459,6 @@ function theListeners(){ ...@@ -424,7 +459,6 @@ function theListeners(){
source: function(request, response) { source: function(request, response) {
matches = []; matches = [];
var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i"); var matcher = new RegExp($.ui.autocomplete.escapeRegex(request.term), "i");
pr(labels);
var results = $.grep(labels, function(e) { var results = $.grep(labels, function(e) {
return matcher.test(e.label); //|| matcher.test(e.desc); return matcher.test(e.label); //|| matcher.test(e.desc);
}); });
...@@ -467,13 +501,11 @@ function theListeners(){ ...@@ -467,13 +501,11 @@ function theListeners(){
for(j=0;j<matches.length;j++){ for(j=0;j<matches.length;j++){
coincidences.push(matches[j].id) coincidences.push(matches[j].id)
} }
pr("coincidencees: ");
pr(coincidences);
$.doTimeout(30,function (){ $.doTimeout(30,function (){
MultipleSelection(coincidences); MultipleSelection(coincidences);
$("input#searchinput").val("");
$("input#searchinput").autocomplete( "close" );
}); });
$("input#searchinput").val("");
$("input#searchinput").autocomplete( "close" );
//$("input#searchinput").trigger('autocompleteclose'); //$("input#searchinput").trigger('autocompleteclose');
} }
} }
...@@ -482,18 +514,13 @@ function theListeners(){ ...@@ -482,18 +514,13 @@ function theListeners(){
$("#searchinput").keyup(function (e) { $("#searchinput").keyup(function (e) {
if (e.keyCode == 13 && $("input#searchinput").data('is_open') !== true) { if (e.keyCode == 13 && $("input#searchinput").data('is_open') !== true) {
pr("search KEY UP"); pr("search KEY UP");
var s = $("#searchinput").val(); var exfnd = exactfind( $("#searchinput").val() )
// pr(s)
// pr(exactfind(s))
$("#searchinput").val(strSearchBar);
var coincidence = exactfind(s);
$.doTimeout(30,function (){ $.doTimeout(30,function (){
MultipleSelection(coincidence.id); MultipleSelection(exfnd.id);
}); $("input#searchinput").val("");
$("input#searchinput").val(""); $("input#searchinput").autocomplete( "close" );
$("input#searchinput").autocomplete( "close" ); });
// if(categoriesIndex.length==1) updateLeftPanel_uni();
// if(categoriesIndex.length==2) updateLeftPanel_fix();
} }
}); });
...@@ -501,7 +528,7 @@ function theListeners(){ ...@@ -501,7 +528,7 @@ function theListeners(){
pr("searchsubmit CLICK"); pr("searchsubmit CLICK");
var s = $("#searchinput").val(); var s = $("#searchinput").val();
search(s); search(s);
$("#searchinput").val(strSearchBar); $("#searchinput").val("");
}); });
/******************* /SEARCH ***********************/ /******************* /SEARCH ***********************/
...@@ -671,7 +698,8 @@ function theListeners(){ ...@@ -671,7 +698,8 @@ function theListeners(){
}); });
// finished // finished
EdgeWeightFilter("#sliderAEdgeWeight", "label" , "nodes1", "weight"); //this should be available at start!!
// EdgeWeightFilter("#sliderAEdgeWeight", "label" , "nodes1", "weight");
//finished //finished
...@@ -731,17 +759,5 @@ function theListeners(){ ...@@ -731,17 +759,5 @@ function theListeners(){
} }
}); });
// $.doTimeout(10,function (){
// var deftoph=$("#defaultop").height();
// var refh=$("#fixedtop").height();
// pr("deftoph:"+deftoph+" vs refh:"+refh)
// pr("deftoph:"+deftoph+" vs refh*2:"+refh*2)
// pr("if deftoph > refh*2 ")
// pr(deftoph+">"+(refh*2)+" : "+(deftoph>(refh*2))+" then reload window")
// // deftoph.height(64);
// // if(deftoph>(refh*2)) window.location.reload();
// });
} }
...@@ -158,6 +158,7 @@ function cancelSelection (fromTagCloud) { ...@@ -158,6 +158,7 @@ function cancelSelection (fromTagCloud) {
} }
deselections={}; deselections={};
// leftPanel("close"); // leftPanel("close");
if(swMacro) LevelButtonDisable(true);
partialGraph.draw(); partialGraph.draw();
} }
...@@ -237,7 +238,10 @@ function RefreshState(newNOW){ ...@@ -237,7 +238,10 @@ function RefreshState(newNOW){
if(is_empty(selections) || i==0) LevelButtonDisable(false); if(is_empty(selections) || i==0) LevelButtonDisable(false);
} }
EdgeWeightFilter("#sliderAEdgeWeight", "label" , "nodes1", "weight"); //this should be available!!
// EdgeWeightFilter("#sliderAEdgeWeight", "label" , "nodes1", "weight");
$("#semLoader").hide();
$("#colorGraph").show(); $("#colorGraph").show();
} }
...@@ -257,10 +261,11 @@ function RefreshState(newNOW){ ...@@ -257,10 +261,11 @@ function RefreshState(newNOW){
i=0; for(var s in selections) { i++; break;} i=0; for(var s in selections) { i++; break;}
if(is_empty(selections) || i==0) LevelButtonDisable(false); if(is_empty(selections) || i==0) LevelButtonDisable(false);
} }
if ( semanticConverged ) $("#semLoader").hide();
else $("#semLoader").show();
EdgeWeightFilter("#sliderBEdgeWeight", "label" , "nodes2", "weight"); //this should be available!!
NodeWeightFilter ( "#sliderBNodeWeight" , "type" , "NGram" , "size") // EdgeWeightFilter("#sliderBEdgeWeight", "label" , "nodes2", "weight");
// NodeWeightFilter ( "#sliderBNodeWeight" , "type" , "NGram" , "size")
$("#colorGraph").hide(); $("#colorGraph").hide();
} }
if(NOW=="AaBb"){ if(NOW=="AaBb"){
...@@ -1110,14 +1115,7 @@ function MultipleSelection(nodes){ ...@@ -1110,14 +1115,7 @@ function MultipleSelection(nodes){
} }
checkBox=false; checkBox=false;
} else { } else {
// pr("=============")
// pr("receiving nodes: ")
// pr(nodes);
// pr("ndsids content: ")
// pr(ndsids)
// pr("selections content PREV: ")
// pr(selections)
for(var i in ndsids){ for(var i in ndsids){
nodeid = ndsids[i] nodeid = ndsids[i]
getOpossitesNodes(nodeid,false); //false -> just nodeid getOpossitesNodes(nodeid,false); //false -> just nodeid
...@@ -1314,17 +1312,44 @@ function hideEverything(){ ...@@ -1314,17 +1312,44 @@ function hideEverything(){
function unHide(id){ function unHide(id){
// i've received a NODE // i've received a NODE
if(id.split(";").length==1){ if(id.split(";").length==1) {
updateSearchLabels(id,Nodes[id].label,Nodes[id].type);
nodeslength++; if(Nodes[id]) {
//visibleNodes.push(id); var anode = ({
if(getn(id)) id:id,
partialGraph._core.graph.nodesIndex[id].hidden=false; label: Nodes[id].label,
size: Nodes[id].size,
x: Nodes[id].x,
y: Nodes[id].y,
type: Nodes[id].type,
color: Nodes[id].color,
shape: Nodes[id].shape
}); // The graph node
updateSearchLabels(id,Nodes[id].label,Nodes[id].type);
nodeslength++;
partialGraph.addNode(id,anode);
return;
}
} }
else {// It's an edge! else {// It's an edge!
//visibleEdges.push(id); //visibleEdges.push(id);
if(gete(id)) if(Edges[id]){
partialGraph._core.graph.edgesIndex[id].hidden=false;
var anedge = {
id: id,
sourceID: Edges[id].sourceID,
targetID: Edges[id].targetID,
lock : false,
label: Edges[id].type,
weight: Edges[id].w
};
partialGraph.addEdge(id , anedge.sourceID , anedge.targetID , anedge);
return;
}
} }
} }
...@@ -1356,7 +1381,6 @@ function add1Edge(ID) { ...@@ -1356,7 +1381,6 @@ function add1Edge(ID) {
} }
} }
function hideElem(id){ function hideElem(id){
if(id.split(";").length==1){ if(id.split(";").length==1){
//updateSearchLabels(id,Nodes[id].label,Nodes[id].type); //updateSearchLabels(id,Nodes[id].label,Nodes[id].type);
...@@ -1561,8 +1585,30 @@ function changeToMacro(iwannagraph) { ...@@ -1561,8 +1585,30 @@ function changeToMacro(iwannagraph) {
labels=[] labels=[]
pr("CHANGING TO Macro-"+iwannagraph); pr("CHANGING TO Macro-"+iwannagraph);
hideEverything(); // pr("BEFORE cancelSelection()")
// for(var i in partialGraph._core.graph.nodesIndex) {
// pr(partialGraph._core.graph.nodesIndex[i].id+" : "+partialGraph._core.graph.nodesIndex[i].color+" <=> "+Nodes[i].id+" : "+Nodes[i].color)
// pr(partialGraph._core.graph.nodesIndex[i])
// pr("")
// }
// pr("--------------------------------------------------------------------------------")
partialGraph.emptyGraph();
if ( iwannagraph=="semantic" && !semanticConverged ) {
partialGraph.draw();
// partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.8);
partialGraph.refresh();
// partialGraph.startForceAtlas2();
$("#semLoader").show();
return;
}
//iwantograph Social OR Semantic
if(iwannagraph!="sociosemantic") { if(iwannagraph!="sociosemantic") {
socsemFlag=false; socsemFlag=false;
category = (iwannagraph=="social")?catSoc:catSem; category = (iwannagraph=="social")?catSoc:catSem;
......
...@@ -276,12 +276,6 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -276,12 +276,6 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
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){
if(numberOfDocs==nodes.length){
socialConverged++;
}
if(numberOfNGrams==nodes.length ){
semanticConverged++;
}
pr("iteraciones: "+self.count) pr("iteraciones: "+self.count)
partialGraph.stopForceAtlas2(); partialGraph.stopForceAtlas2();
} }
...@@ -998,64 +992,64 @@ sigma.publicPrototype.startForceAtlas2 = function() { ...@@ -998,64 +992,64 @@ sigma.publicPrototype.startForceAtlas2 = function() {
//if(!this.forceatlas2) { //if(!this.forceatlas2) {
if(fa2enabled) { if(fa2enabled) {
// -- UPDATING THE DEGREE -- // // -- UPDATING THE DEGREE --
for (var i in this._core.graph.nodesIndex) { // for (var i in this._core.graph.nodesIndex) {
pr(i+" -> "+this._core.graph.nodesIndex[i].degree) // pr(i+" -> "+this._core.graph.nodesIndex[i].degree)
} // }
for (var i in this._core.graph.nodes) { // for (var i in this._core.graph.nodes) {
if(!this._core.graph.nodes[i].hidden) { // if(!this._core.graph.nodes[i].hidden) {
this._core.graph.nodes[i].degree = 0; // this._core.graph.nodes[i].degree = 0;
this._core.graph.nodesIndex[this._core.graph.nodes[i].id].degree = 0; // this._core.graph.nodesIndex[this._core.graph.nodes[i].id].degree = 0;
} // }
} // }
for (var e in this._core.graph.edges) { // for (var e in this._core.graph.edges) {
edge = this._core.graph.edges[e]; // edge = this._core.graph.edges[e];
if(!edge.hidden) { // if(!edge.hidden) {
nodeIDS = edge.source.id; // nodeIDS = edge.source.id;
nodeIDT = edge.target.id; // nodeIDT = edge.target.id;
this._core.graph.nodesIndex[nodeIDS].degree++; // this._core.graph.nodesIndex[nodeIDS].degree++;
this._core.graph.nodesIndex[nodeIDT].degree++; // this._core.graph.nodesIndex[nodeIDT].degree++;
} // }
} // }
for (var i in this._core.graph.nodes) { // for (var i in this._core.graph.nodes) {
if(!this._core.graph.nodes[i].hidden && this._core.graph.nodes[i].degree>0) { // if(!this._core.graph.nodes[i].hidden && this._core.graph.nodes[i].degree>0) {
if(this._core.graph.nodes[i].x < minx) minx = this._core.graph.nodes[i].x // if(this._core.graph.nodes[i].x < minx) minx = this._core.graph.nodes[i].x
if(this._core.graph.nodes[i].x > maxx) maxx = this._core.graph.nodes[i].x // if(this._core.graph.nodes[i].x > maxx) maxx = this._core.graph.nodes[i].x
if(this._core.graph.nodes[i].y < miny) miny = this._core.graph.nodes[i].y // if(this._core.graph.nodes[i].y < miny) miny = this._core.graph.nodes[i].y
if(this._core.graph.nodes[i].y > maxy) maxy = this._core.graph.nodes[i].y // if(this._core.graph.nodes[i].y > maxy) maxy = this._core.graph.nodes[i].y
} // }
} // }
var ybuffer = miny; // var ybuffer = miny;
for (var i in this._core.graph.nodesIndex) { // for (var i in this._core.graph.nodesIndex) {
if(this._core.graph.nodesIndex[i].degree==0) { // if(this._core.graph.nodesIndex[i].degree==0) {
// this._core.graph.nodesIndex[i].color = "#000000" // // this._core.graph.nodesIndex[i].color = "#000000"
this._core.graph.nodesIndex[i].x = minx-10 // this._core.graph.nodesIndex[i].x = minx-10
this._core.graph.nodesIndex[i].y = ybuffer // this._core.graph.nodesIndex[i].y = ybuffer
this._core.graph.nodesIndex[i].displayX = minx-10 // this._core.graph.nodesIndex[i].displayX = minx-10
this._core.graph.nodesIndex[i].displayY = ybuffer // this._core.graph.nodesIndex[i].displayY = ybuffer
// this._core.graph.nodesIndex[i].hidden = true; // // this._core.graph.nodesIndex[i].hidden = true;
// this._core.graph.nodesIndex[i].fixed = true; // // this._core.graph.nodesIndex[i].fixed = true;
ybuffer = ybuffer + Math.pow(this._core.graph.nodesIndex[i].displaySize,2); // ybuffer = ybuffer + Math.pow(this._core.graph.nodesIndex[i].displaySize,2);
pr(ybuffer) // pr(ybuffer)
} // }
// this._core.graph.nodesIndex[i].hidden = true; // // this._core.graph.nodesIndex[i].hidden = true;
pr(i+" -> "+this._core.graph.nodesIndex[i].degree) // pr(i+" -> "+this._core.graph.nodesIndex[i].degree)
} // }
// -- / UPDATING THE DEGREE -- // // -- / UPDATING THE DEGREE --
pr("minx: "+minx) // pr("minx: "+minx)
pr("maxx: "+maxx) // pr("maxx: "+maxx)
pr("miny: "+miny) // pr("miny: "+miny)
pr("maxy: "+maxy) // pr("maxy: "+maxy)
pr("") // pr("")
var V = 10; var V = 10;
var E = 100; var E = 100;
...@@ -1100,10 +1094,10 @@ sigma.publicPrototype.stopForceAtlas2 = function() { ...@@ -1100,10 +1094,10 @@ sigma.publicPrototype.stopForceAtlas2 = function() {
// this._core.graph.nodesIndex[i].fixed = true; // this._core.graph.nodesIndex[i].fixed = true;
ybuffer = ybuffer + Math.pow(this._core.graph.nodesIndex[i].displaySize,2); ybuffer = ybuffer + Math.pow(this._core.graph.nodesIndex[i].displaySize,2);
pr(ybuffer) // pr(ybuffer)
} }
// this._core.graph.nodesIndex[i].hidden = true; // this._core.graph.nodesIndex[i].hidden = true;
pr(i+" -> "+this._core.graph.nodesIndex[i].degree) // pr(i+" -> "+this._core.graph.nodesIndex[i].degree)
} }
// -- / UPDATING THE DEGREE -- // -- / UPDATING THE DEGREE --
......
...@@ -1078,17 +1078,26 @@ sigma.classes.Cascade = function() { ...@@ -1078,17 +1078,26 @@ sigma.classes.Cascade = function() {
// var ident = params.sourceID.charAt(0)+params.targetID.charAt(0); // var ident = params.sourceID.charAt(0)+params.targetID.charAt(0);
var color; //edge color will be the combination of the 2 node colors
var a = self.nodesIndex[source]['color'];
var b = self.nodesIndex[target]['color'];
a = hex2rga(a);
b = hex2rga(b);
var r = (a[0] + b[0]) >> 1;
var g = (a[1] + b[1]) >> 1;
var b = (a[2] + b[2]) >> 1;
var color = '#'+sigma.tools.rgbToHex(parseFloat(r),parseFloat(g),parseFloat(b))
//pr(params.label); //pr(params.label);
if(params.label=="nodes1") { // if(params.label=="nodes1") {
color = "#cedc75"; // color = "#cedc75";
} // }
if(params.label=="nodes2") { // if(params.label=="nodes2") {
color = "#f4c673"; // color = "#f4c673";
} // }
if(params.label=="bipartite") { // if(params.label=="bipartite") {
color = "#7e9bc2"; // color = "#7e9bc2";
} // }
params = params || {}; params = params || {};
var e = { var e = {
...@@ -1252,35 +1261,7 @@ sigma.classes.Cascade = function() { ...@@ -1252,35 +1261,7 @@ sigma.classes.Cascade = function() {
* @return {Graph} Returns itself. * @return {Graph} Returns itself.
*/ */
function empty() { function empty() {
// res=document.getElementById("viewType").src.indexOf("meso");
// if(typeof(self.nodes)!=="undefined" && self.nodes.length != (numberOfDocs+numberOfNGrams) && res==-1) {
// //pr("swclickActual: "+swclickActual+" - #partialGraph.nodes: "+self.nodes.length+" - #docs: "+numberOfDocs+" - #ngrams: "+numberOfNGrams);
// //pr(document.getElementById("viewType").src);
// if(swclickActual=="social" && semanticConverged<2){
// pr("I've clicked swclick: social - semanticConverged?: "+semanticConverged+" - updating semanticGraph positions");
// if(semanticConverged===1) semanticConverged++;
// for(var n in self.nodes){
// /**/
// //Saving the positions in Nodes before dropping the partialGraph
// //The sociosemantic spatialization is a little
// //bit different than the two others
// Nodes[self.nodes[n].id].x=self.nodes[n].x;
// Nodes[self.nodes[n].id].y=self.nodes[n].y;
// }
// }
// if(swclickActual=="semantic" && socialConverged<2){
// pr("I've clicked swclick: semantic - socialConverged?: "+socialConverged+" - updating socialGraph positions");
// if(socialConverged===1) socialConverged++;
// for(var n in self.nodes){
// /**/
// //Saving the positions in Nodes before dropping the partialGraph
// //The sociosemantic spatialization is a little
// //bit different than the two others
// Nodes[self.nodes[n].id].x=self.nodes[n].x;
// Nodes[self.nodes[n].id].y=self.nodes[n].y;
// }
// }
// }
self.nodes = []; self.nodes = [];
self.nodesIndex = {}; self.nodesIndex = {};
self.edges = []; self.edges = [];
...@@ -2293,21 +2274,31 @@ sigma.classes.Cascade = function() { ...@@ -2293,21 +2274,31 @@ sigma.classes.Cascade = function() {
var y2 = edge['target']['displayY']; var y2 = edge['target']['displayY'];
var color = edge['color']; var color = edge['color'];
if (!color) { if(!color) {
switch (self.p.edgeColor) { var a = edge['source']['color'];
case 'source': var b = edge['target']['color'];
color = edge['source']['color'] || a = hex2rga(a);
self.p.defaultNodeColor; b = hex2rga(b);
break; var r = (a[0] + b[0]) >> 1;
case 'target': var g = (a[1] + b[1]) >> 1;
color = edge['target']['color'] || var b = (a[2] + b[2]) >> 1;
self.p.defaultNodeColor; color = '#'+sigma.tools.rgbToHex(parseFloat(r),parseFloat(g),parseFloat(b))
break; }
default: // if (!color) {
color = self.p.defaultEdgeColor; // switch (self.p.edgeColor) {
break; // case 'source':
} // color = edge['source']['color'] ||
} // self.p.defaultNodeColor;
// break;
// case 'target':
// color = edge['target']['color'] ||
// self.p.defaultNodeColor;
// break;
// default:
// color = self.p.defaultEdgeColor;
// break;
// }
// }
var ctx = edgesCtx; var ctx = edgesCtx;
......
...@@ -643,12 +643,14 @@ function extractFromJson(data,seed){ ...@@ -643,12 +643,14 @@ function extractFromJson(data,seed){
Nodes[i].size = ""+normalizedSize; Nodes[i].size = ""+normalizedSize;
nodeK = Nodes[i]; nodeK = Nodes[i];
nodeK.hidden=true;/**///should be uncommented otherGraph.addNode(i,nodeK);
partialGraph.addNode(i,nodeK); // nodeK.hidden=true;/**///should be uncommented
// partialGraph.addNode(i,nodeK);
} }
else { else {
partialGraph.addNode(i,Nodes[i]); partialGraph.addNode(i,Nodes[i]);
unHide(i); updateSearchLabels(i,Nodes[i].label,Nodes[i].type);
// unHide(i);
} }
// pr(Nodes[i]) // pr(Nodes[i])
} }
...@@ -673,11 +675,8 @@ function extractFromJson(data,seed){ ...@@ -673,11 +675,8 @@ function extractFromJson(data,seed){
if(edge.weight > maxEdgeWeight) maxEdgeWeight= edge.weight; if(edge.weight > maxEdgeWeight) maxEdgeWeight= edge.weight;
Edges[indice] = edge; Edges[indice] = edge;
if(edge.label=="nodes1"){ if(edge.label=="nodes1"){
edge.hidden=false; // edge.hidden=false;
if(isUndef(nodes1[source])) { if(isUndef(nodes1[source])) {
nodes1[source] = { nodes1[source] = {
...@@ -693,11 +692,13 @@ function extractFromJson(data,seed){ ...@@ -693,11 +692,13 @@ function extractFromJson(data,seed){
} }
nodes1[source].neighbours.push(target); nodes1[source].neighbours.push(target);
nodes1[target].neighbours.push(source); nodes1[target].neighbours.push(source);
partialGraph.addEdge(indice,source,target,edge);
} }
if(edge.label=="nodes2"){ if(edge.label=="nodes2"){
edge.hidden=true; // edge.hidden=true;
if(isUndef(nodes2[source])) { if(isUndef(nodes2[source])) {
nodes2[source] = { nodes2[source] = {
...@@ -713,11 +714,13 @@ function extractFromJson(data,seed){ ...@@ -713,11 +714,13 @@ function extractFromJson(data,seed){
} }
nodes2[source].neighbours.push(target); nodes2[source].neighbours.push(target);
nodes2[target].neighbours.push(source); nodes2[target].neighbours.push(source);
otherGraph.addEdge(indice,source,target,edge);
} }
if(edge.label=="bipartite"){ if(edge.label=="bipartite"){
edge.hidden=true; // edge.hidden=true;
s = edge.sourceID s = edge.sourceID
...@@ -761,6 +764,5 @@ function extractFromJson(data,seed){ ...@@ -761,6 +764,5 @@ function extractFromJson(data,seed){
} }
//edge.hidden=false/**///should be commented //edge.hidden=false/**///should be commented
partialGraph.addEdge(indice,source,target,edge);
} }
} }
...@@ -35,6 +35,7 @@ function showMeSomeLabels(N){ ...@@ -35,6 +35,7 @@ function showMeSomeLabels(N){
if(counter==N) break; if(counter==N) break;
} }
} }
partialGraph.draw()
/*======= Show some labels at the beginning =======*/ /*======= Show some labels at the beginning =======*/
} }
......
...@@ -31,7 +31,7 @@ function test2 { ...@@ -31,7 +31,7 @@ function test2 {
for f in $iter for f in $iter
do do
filename=`echo $f | sed s/"\.\/"//g` filename=`echo $f | sed s/"\.\/"//g`
variable=`cat $filename | grep "greyColor"` variable=`cat $filename | grep "semanticConverged"`
if [[ "$variable" != "" ]] if [[ "$variable" != "" ]]
then then
echo $filename echo $filename
......
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