Commit b38dc494 authored by PkSM3's avatar PkSM3

new bipartite interaction

parent ddf70c01
...@@ -10,6 +10,7 @@ var mainfile=false; ...@@ -10,6 +10,7 @@ var mainfile=false;
var dataFolderTree = {}; var dataFolderTree = {};
var gexfDict={}; var gexfDict={};
var egonode = {} var egonode = {}
var iwantograph = "";
var bridge={}; var bridge={};
external=""; external="";
......
...@@ -3,8 +3,7 @@ ...@@ -3,8 +3,7 @@
//============================ < NEW BUTTONS > =============================// //============================ < NEW BUTTONS > =============================//
function changeType() { function changeType() {
pr("***swclickActual:"+swclickActual+" , swMacro:"+swMacro) pr("***swclickActual:"+swclickActual+" , swMacro:"+swMacro);
// partialGraph.stopForceAtlas2();
if(swclickActual=="social") { if(swclickActual=="social") {
if(swMacro) { if(swMacro) {
...@@ -51,7 +50,10 @@ function changeType() { ...@@ -51,7 +50,10 @@ function changeType() {
} }
if(swclickActual=="sociosemantic") { if(swclickActual=="sociosemantic") {
pr("click en changeType y estoy en SocioSemantic, swMacro:"+swMacro+"|selections:");
pr(selections)
if(swMacro) { if(swMacro) {
changeToMacro("sociosemantic"); changeToMacro("sociosemantic");
pushSWClick("sociosemantic"); pushSWClick("sociosemantic");
...@@ -63,9 +65,63 @@ function changeType() { ...@@ -63,9 +65,63 @@ function changeType() {
pushSWClick(swclickPrev); pushSWClick(swclickPrev);
RefreshState(PAST.toUpperCase()) RefreshState(PAST.toUpperCase())
} else { } else {
pushSWClick(swclickPrev); //there is an active selection
changeToMeso(swclickActual);
RefreshState(PAST) //identify type of the current-selection
var countTypes = {};
pr("identify type of the current-selection")
for(var i in selections) {
if( isUndef(countTypes[Nodes[i].type]) )
countTypes[Nodes[i].type]=1;
else
countTypes[Nodes[i].type]++;
}
pr("#selectionsTypes: ")
pr(countTypes)
cpCountTypes = Object.keys(countTypes);
if(cpCountTypes.length==1) {
if(cpCountTypes[0]==catSoc) {
pr("FROM MESO-SOCIOSEMANTIC TO MESO-SOCIAL")
pushSWClick("social");
changeToMeso("social");
RefreshState("a");
} else {
pushSWClick("semantic");
changeToMeso("semantic");
RefreshState("b");
}
} else {
//there is a selection of both kind of nodes
//
var ndsids = [];
for(var i in selections) {
if( Nodes[i].type == catSoc )
ndsids.push(i);
}
cancelSelection(false);
for(var i in ndsids){
nodeid = ndsids[i]
getOpossitesNodes(nodeid,false); //false -> just nodeid
// markAsSelected(nodeid,true);
}
pushSWClick("social");
changeToMeso("social");
RefreshState("a");
}
// pushSWClick(swclickPrev);
// changeToMeso(swclickActual);
// RefreshState(PAST)
} }
} }
// if(swMacro) { // if(swMacro) {
......
...@@ -512,9 +512,6 @@ function theListeners(){ ...@@ -512,9 +512,6 @@ function theListeners(){
}); });
$("#edgesButton").click(function () { $("#edgesButton").click(function () {
pr("click en #edgesButton")
pr(partialGraph.forceatlas2)
fa2enabled=true; fa2enabled=true;
if(!isUndef(partialGraph.forceatlas2)) { if(!isUndef(partialGraph.forceatlas2)) {
......
...@@ -444,20 +444,6 @@ function getOpossitesNodes(node_id, entireNode) { ...@@ -444,20 +444,6 @@ function getOpossitesNodes(node_id, entireNode) {
opos = ArraySortByValue(opossites, function(a,b){ opos = ArraySortByValue(opossites, function(a,b){
return b-a return b-a
}); });
// console.log("WOLOLO WOLOLO WOLOLO WOLOLO");
// $.ajax({
// type: 'GET',
// url: 'http://localhost/getJsonFromUrl/tagcloud.php',
// data: "url="+JSON.stringify(opos),
// //contentType: "application/json",
// //dataType: 'json',
// success : function(data){
// console.log(data);
// },
// error: function(){
// pr("Page Not found.");
// }
// });
} }
//to sigma utils! //to sigma utils!
...@@ -1349,6 +1335,7 @@ function hideEverything(){ ...@@ -1349,6 +1335,7 @@ function hideEverything(){
function unHide(id){ function unHide(id){
// pr("in unhide "+iwantograph+" | swMacro: "+swMacro)
if(id.split(";").length==1) { if(id.split(";").length==1) {
// i've received a NODE // i've received a NODE
if(Nodes[id]) { if(Nodes[id]) {
...@@ -1383,7 +1370,7 @@ function unHide(id){ ...@@ -1383,7 +1370,7 @@ function unHide(id){
targetID: Edges[id].targetID, targetID: Edges[id].targetID,
lock : false, lock : false,
label: Edges[id].label, label: Edges[id].label,
weight: Edges[id].weight weight: (swMacro && (iwantograph=="sociosemantic"))?Edges[id].bweight:Edges[id].weight
}; };
partialGraph.addEdge(id , anedge.sourceID , anedge.targetID , anedge); partialGraph.addEdge(id , anedge.sourceID , anedge.targetID , anedge);
...@@ -1449,11 +1436,10 @@ function unHideElem(id){ ...@@ -1449,11 +1436,10 @@ function unHideElem(id){
function changeToMeso(iwannagraph) { function changeToMeso(iwannagraph) {
labels=[] labels=[]
// partialGraph.stopForceAtlas2(); iwantograph=iwannagraph;//just a mess
partialGraph.emptyGraph(); partialGraph.emptyGraph();
if(partialGraph.forceatlas2)
pr("t=2: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
pr("changing to Meso-"+iwannagraph); pr("changing to Meso-"+iwannagraph);
if(iwannagraph=="social") { if(iwannagraph=="social") {
if(!is_empty(selections)){ if(!is_empty(selections)){
...@@ -1550,12 +1536,8 @@ function changeToMeso(iwannagraph) { ...@@ -1550,12 +1536,8 @@ function changeToMeso(iwannagraph) {
if(iwannagraph=="sociosemantic") { if(iwannagraph=="sociosemantic") {
if(partialGraph.forceatlas2)
pr("t=3: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
if(!is_empty(selections) && !is_empty(opossites)){ if(!is_empty(selections) && !is_empty(opossites)){
pr("ESTOY DENTRO DE SOCIOSEMANTIC!!!")
// hideEverything();
for(var i in selections) { for(var i in selections) {
unHide(i); unHide(i);
} }
...@@ -1564,13 +1546,8 @@ function changeToMeso(iwannagraph) { ...@@ -1564,13 +1546,8 @@ function changeToMeso(iwannagraph) {
unHide(i); unHide(i);
} }
if(partialGraph.forceatlas2)
pr("t=4: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
createEdgesForExistingNodes(iwannagraph); createEdgesForExistingNodes(iwannagraph);
if(partialGraph.forceatlas2)
pr("t=5: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
socsemFlag=true; socsemFlag=true;
} }
...@@ -1578,10 +1555,6 @@ function changeToMeso(iwannagraph) { ...@@ -1578,10 +1555,6 @@ function changeToMeso(iwannagraph) {
// NodeWeightFilter ( "#sliderBNodeWeight" , "type" , "NGram" , "size") // NodeWeightFilter ( "#sliderBNodeWeight" , "type" , "NGram" , "size")
// EdgeWeightFilter("#sliderAEdgeWeight", "label" , "nodes1", "weight"); // EdgeWeightFilter("#sliderAEdgeWeight", "label" , "nodes1", "weight");
$("#colorGraph").hide(); $("#colorGraph").hide();
if(partialGraph.forceatlas2)
pr("t=6: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
} }
if(iwannagraph=="semantic") { if(iwannagraph=="semantic") {
...@@ -1659,13 +1632,9 @@ function changeToMeso(iwannagraph) { ...@@ -1659,13 +1632,9 @@ function changeToMeso(iwannagraph) {
$("#colorGraph").hide(); $("#colorGraph").hide();
} }
if(partialGraph.forceatlas2)
pr("t=7: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
fa2enabled=true; partialGraph.startForceAtlas2(); fa2enabled=true; partialGraph.startForceAtlas2();
MultipleSelection(Object.keys(selections));
MultipleSelection(Object.keys(selections));
$('.gradient').css({"background-size":"90px 90px"}); $('.gradient').css({"background-size":"90px 90px"});
} }
...@@ -1674,7 +1643,8 @@ function changeToMacro(iwannagraph) { ...@@ -1674,7 +1643,8 @@ function changeToMacro(iwannagraph) {
labels=[] labels=[]
pr("CHANGING TO Macro-"+iwannagraph); pr("CHANGING TO Macro-"+iwannagraph);
// partialGraph.stopForceAtlas2(); iwantograph=iwannagraph;//just a mess
partialGraph.emptyGraph(); partialGraph.emptyGraph();
if ( iwannagraph=="semantic" && !semanticConverged ) { if ( iwannagraph=="semantic" && !semanticConverged ) {
......
...@@ -338,8 +338,8 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -338,8 +338,8 @@ 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)){
pr("iteraciones: "+self.count) pr("i've applied the stopcriteria: "+self.count)
partialGraph.stopForceAtlas2(); partialGraph.stopForceAtlas2();
} }
...@@ -477,18 +477,12 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) { ...@@ -477,18 +477,12 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
} }
// pr("\t in case 5, i="+i+" | nbnodes="+nodes.length)
// pr("\tstate index: "+self.state.index)
// pr("\tthe self.count: "+self.count)
if (i == nodes.length) { if (i == nodes.length) {
self.state.step = 0; self.state.step = 0;
self.state.index = 0; self.state.index = 0;
// pr("\t\tafter the thing")
return false; return false;
} else { } else {
self.state.index = i; self.state.index = i;
// pr("else state index: "+self.state.index)
return true; return true;
} }
...@@ -1182,18 +1176,10 @@ sigma.publicPrototype.startForceAtlas2 = function() { ...@@ -1182,18 +1176,10 @@ sigma.publicPrototype.startForceAtlas2 = function() {
var V = 10; var V = 10;
var E = 100; var E = 100;
if(partialGraph.forceatlas2)
pr("t=8: in startfa2 : forceatlas2.active = "+partialGraph.forceatlas2.active)
this.forceatlas2 = new sigma.forceatlas2.ForceAtlas2(this._core.graph , V, E); this.forceatlas2 = new sigma.forceatlas2.ForceAtlas2(this._core.graph , V, E);
this.forceatlas2.setAutoSettings(); this.forceatlas2.setAutoSettings();
this.forceatlas2.init(); this.forceatlas2.init();
if(partialGraph.forceatlas2)
pr("t=9: in startfa2 : forceatlas2.active = "+partialGraph.forceatlas2.active)
this.forceatlas2.active=true; this.forceatlas2.active=true;
pr("\t\t\t\t\tFA2 Started") pr("\t\t\t\t\tFA2 Started")
var ene = this._core.graph.nodes.length; var ene = this._core.graph.nodes.length;
...@@ -1202,12 +1188,6 @@ sigma.publicPrototype.startForceAtlas2 = function() { ...@@ -1202,12 +1188,6 @@ sigma.publicPrototype.startForceAtlas2 = function() {
if(this._core.graph.nodesIndex[i].degree==0) isolatedBCauseFilter++; if(this._core.graph.nodesIndex[i].degree==0) isolatedBCauseFilter++;
} }
if(partialGraph.forceatlas2)
pr("t=10: in startfa2 : forceatlas2.active = "+partialGraph.forceatlas2.active)
pr("|||||||||| isolatedBCauseFilter "+isolatedBCauseFilter)
pr("|||||||||| ene "+ene)
pr("isolatedBCauseFilter==ene = "+(isolatedBCauseFilter==ene))
if(isolatedBCauseFilter==ene) { if(isolatedBCauseFilter==ene) {
partialGraph.stopForceAtlas2(); partialGraph.stopForceAtlas2();
return; return;
...@@ -1220,18 +1200,13 @@ sigma.publicPrototype.startForceAtlas2 = function() { ...@@ -1220,18 +1200,13 @@ sigma.publicPrototype.startForceAtlas2 = function() {
return true; return true;
}); });
pr(getClientTime()+"\tjust before addGenerator | fa2.active:"+partialGraph.forceatlas2.active+" | fa2.count: "+partialGraph.forceatlas2.count); // fixing anomaly in forceatlas2
$.doTimeout(250,function (){ $.doTimeout(250,function (){
pr(getClientTime()+"\tjust after addGenerator | fa2.active:"+partialGraph.forceatlas2.active+" | fa2.count: "+partialGraph.forceatlas2.count);
if( partialGraph.forceatlas2.active && partialGraph.forceatlas2.count==0 ) { if( partialGraph.forceatlas2.active && partialGraph.forceatlas2.count==0 ) {
pr("SUPER TECHNIQUE") pr("SUPER TECHNIQUE!!")
partialGraph.startForceAtlas2(); partialGraph.startForceAtlas2();
return; return;
} }
}); });
} }
......
...@@ -1276,9 +1276,7 @@ sigma.classes.Cascade = function() { ...@@ -1276,9 +1276,7 @@ sigma.classes.Cascade = function() {
if(partialGraph) { if(partialGraph) {
if(partialGraph.forceatlas2) { if(partialGraph.forceatlas2) {
pr("t=0: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
partialGraph.stopForceAtlas2(); partialGraph.stopForceAtlas2();
pr("t=1: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
} }
} }
......
...@@ -686,11 +686,10 @@ function extractFromJson(data,seed){ ...@@ -686,11 +686,10 @@ function extractFromJson(data,seed){
var edgeId = 0; var edgeId = 0;
var edgesNodes = data.edges; var edgesNodes = data.edges;
for(var i in edgesNodes) { for(var i in edgesNodes) {
//pr(edgesNodes[i]);
var source = edgesNodes[i].s; var source = edgesNodes[i].s;
var target = edgesNodes[i].t; var target = edgesNodes[i].t;
var indice=source+";"+target; var indice=source+";"+target;
// if(indice.indexOf("D::593")!==-1) pr(indice)
var edge = { var edge = {
id: indice, id: indice,
sourceID: source, sourceID: source,
...@@ -702,98 +701,98 @@ function extractFromJson(data,seed){ ...@@ -702,98 +701,98 @@ function extractFromJson(data,seed){
if(edge.weight < minEdgeWeight) minEdgeWeight= edge.weight; if(edge.weight < minEdgeWeight) minEdgeWeight= edge.weight;
if(edge.weight > maxEdgeWeight) maxEdgeWeight= edge.weight; if(edge.weight > maxEdgeWeight) maxEdgeWeight= edge.weight;
Edges[indice] = edge; Edges[indice] = edge;
if(edge.label=="nodes1"){
// edge.hidden=false;
if(isUndef(nodes1[source])) {
nodes1[source] = {
label: Nodes[source].label,
neighbours: []
};
}
if(isUndef(nodes1[target])) {
nodes1[target] = {
label: Nodes[target].label,
neighbours: []
};
}
nodes1[source].neighbours.push(target);
nodes1[target].neighbours.push(source);
// social edges = 1
Edges[indice].bweight = edgesNodes[i].w;//realweight as in bigraph-weight
edge.weight = 1;
partialGraph.addEdge(indice,source,target,edge);
}
if(edge.label=="nodes1"){ if(edge.label=="nodes2"){
// edge.hidden=false; // edge.hidden=true;
if(isUndef(nodes1[source])) { if(isUndef(nodes2[source])) {
nodes1[source] = { nodes2[source] = {
label: Nodes[source].label,
neighbours: []
};
}
if(isUndef(nodes2[target])) {
nodes2[target] = {
label: Nodes[target].label,
neighbours: []
};
}
nodes2[source].neighbours.push(target);
nodes2[target].neighbours.push(source);
otherGraph.addEdge(indice,source,target,edge);
}
if(edge.label=="bipartite"){
// edge.hidden=true;
s = edge.sourceID
// // Source is Document
if(Nodes[s].type == catSoc) {
if(isUndef(bipartiteD2N[source])) {
bipartiteD2N[source] = {
label: Nodes[source].label, label: Nodes[source].label,
neighbours: [] neighbours: []
}; };
} }
if(isUndef(nodes1[target])) { if(isUndef(bipartiteN2D[target])) {
nodes1[target] = { bipartiteN2D[target] = {
label: Nodes[target].label, label: Nodes[target].label,
neighbours: [] neighbours: []
}; };
} }
nodes1[source].neighbours.push(target);
nodes1[target].neighbours.push(source);
// social edges = 1 bipartiteD2N[source].neighbours.push(target);
Edges[indice].weight = 1; bipartiteN2D[target].neighbours.push(source);
edge.weight = 1;
partialGraph.addEdge(indice,source,target,edge); // // Source is NGram
} } else {
if(edge.label=="nodes2"){
// edge.hidden=true;
if(isUndef(nodes2[source])) { if(isUndef(bipartiteN2D[source])) {
nodes2[source] = { bipartiteN2D[source] = {
label: Nodes[source].label, label: Nodes[source].label,
neighbours: [] neighbours: []
}; };
} }
if(isUndef(nodes2[target])) { if(isUndef(bipartiteD2N[target])) {
nodes2[target] = { bipartiteD2N[target] = {
label: Nodes[target].label, label: Nodes[target].label,
neighbours: [] neighbours: []
}; };
} }
nodes2[source].neighbours.push(target); bipartiteN2D[source].neighbours.push(target);
nodes2[target].neighbours.push(source); bipartiteD2N[target].neighbours.push(source);
otherGraph.addEdge(indice,source,target,edge);
}
if(edge.label=="bipartite"){
// edge.hidden=true;
s = edge.sourceID
// // Source is Document
if(Nodes[s].type == catSoc) {
if(isUndef(bipartiteD2N[source])) {
bipartiteD2N[source] = {
label: Nodes[source].label,
neighbours: []
};
}
if(isUndef(bipartiteN2D[target])) {
bipartiteN2D[target] = {
label: Nodes[target].label,
neighbours: []
};
}
bipartiteD2N[source].neighbours.push(target);
bipartiteN2D[target].neighbours.push(source);
// // Source is NGram
} else {
if(isUndef(bipartiteN2D[source])) {
bipartiteN2D[source] = {
label: Nodes[source].label,
neighbours: []
};
}
if(isUndef(bipartiteD2N[target])) {
bipartiteD2N[target] = {
label: Nodes[target].label,
neighbours: []
};
}
bipartiteN2D[source].neighbours.push(target);
bipartiteD2N[target].neighbours.push(source);
}
} }
}
//edge.hidden=false/**///should be commented //edge.hidden=false/**///should be commented
} }
......
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