Commit b38dc494 authored by PkSM3's avatar PkSM3

new bipartite interaction

parent ddf70c01
......@@ -10,6 +10,7 @@ var mainfile=false;
var dataFolderTree = {};
var gexfDict={};
var egonode = {}
var iwantograph = "";
var bridge={};
external="";
......
......@@ -3,8 +3,7 @@
//============================ < NEW BUTTONS > =============================//
function changeType() {
pr("***swclickActual:"+swclickActual+" , swMacro:"+swMacro)
// partialGraph.stopForceAtlas2();
pr("***swclickActual:"+swclickActual+" , swMacro:"+swMacro);
if(swclickActual=="social") {
if(swMacro) {
......@@ -51,7 +50,10 @@ function changeType() {
}
if(swclickActual=="sociosemantic") {
pr("click en changeType y estoy en SocioSemantic, swMacro:"+swMacro+"|selections:");
pr(selections)
if(swMacro) {
changeToMacro("sociosemantic");
pushSWClick("sociosemantic");
......@@ -63,9 +65,63 @@ function changeType() {
pushSWClick(swclickPrev);
RefreshState(PAST.toUpperCase())
} else {
pushSWClick(swclickPrev);
changeToMeso(swclickActual);
RefreshState(PAST)
//there is an active selection
//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) {
......
......@@ -512,9 +512,6 @@ function theListeners(){
});
$("#edgesButton").click(function () {
pr("click en #edgesButton")
pr(partialGraph.forceatlas2)
fa2enabled=true;
if(!isUndef(partialGraph.forceatlas2)) {
......
......@@ -444,20 +444,6 @@ function getOpossitesNodes(node_id, entireNode) {
opos = ArraySortByValue(opossites, function(a,b){
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!
......@@ -1349,6 +1335,7 @@ function hideEverything(){
function unHide(id){
// pr("in unhide "+iwantograph+" | swMacro: "+swMacro)
if(id.split(";").length==1) {
// i've received a NODE
if(Nodes[id]) {
......@@ -1383,7 +1370,7 @@ function unHide(id){
targetID: Edges[id].targetID,
lock : false,
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);
......@@ -1449,11 +1436,10 @@ function unHideElem(id){
function changeToMeso(iwannagraph) {
labels=[]
// partialGraph.stopForceAtlas2();
iwantograph=iwannagraph;//just a mess
partialGraph.emptyGraph();
if(partialGraph.forceatlas2)
pr("t=2: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
pr("changing to Meso-"+iwannagraph);
if(iwannagraph=="social") {
if(!is_empty(selections)){
......@@ -1550,12 +1536,8 @@ function changeToMeso(iwannagraph) {
if(iwannagraph=="sociosemantic") {
if(partialGraph.forceatlas2)
pr("t=3: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
if(!is_empty(selections) && !is_empty(opossites)){
pr("ESTOY DENTRO DE SOCIOSEMANTIC!!!")
// hideEverything();
for(var i in selections) {
unHide(i);
}
......@@ -1564,13 +1546,8 @@ function changeToMeso(iwannagraph) {
unHide(i);
}
if(partialGraph.forceatlas2)
pr("t=4: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
createEdgesForExistingNodes(iwannagraph);
if(partialGraph.forceatlas2)
pr("t=5: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
socsemFlag=true;
}
......@@ -1578,10 +1555,6 @@ function changeToMeso(iwannagraph) {
// NodeWeightFilter ( "#sliderBNodeWeight" , "type" , "NGram" , "size")
// EdgeWeightFilter("#sliderAEdgeWeight", "label" , "nodes1", "weight");
$("#colorGraph").hide();
if(partialGraph.forceatlas2)
pr("t=6: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
}
if(iwannagraph=="semantic") {
......@@ -1659,13 +1632,9 @@ function changeToMeso(iwannagraph) {
$("#colorGraph").hide();
}
if(partialGraph.forceatlas2)
pr("t=7: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
fa2enabled=true; partialGraph.startForceAtlas2();
MultipleSelection(Object.keys(selections));
MultipleSelection(Object.keys(selections));
$('.gradient').css({"background-size":"90px 90px"});
}
......@@ -1674,7 +1643,8 @@ function changeToMacro(iwannagraph) {
labels=[]
pr("CHANGING TO Macro-"+iwannagraph);
// partialGraph.stopForceAtlas2();
iwantograph=iwannagraph;//just a mess
partialGraph.emptyGraph();
if ( iwannagraph=="semantic" && !semanticConverged ) {
......
......@@ -338,8 +338,8 @@ sigma.forceatlas2.ForceAtlas2 = function(graph , V , E) {
var convg= ((Math.pow(nodes.length,2))/promdxdy); /**/
var swingingVSnodes_length = swingingSum/nodes.length; /**/
if(stopcriteria && convg > swingingVSnodes_length){
pr("iteraciones: "+self.count)
if(stopcriteria && (convg > swingingVSnodes_length)){
pr("i've applied the stopcriteria: "+self.count)
partialGraph.stopForceAtlas2();
}
......@@ -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) {
self.state.step = 0;
self.state.index = 0;
// pr("\t\tafter the thing")
return false;
} else {
self.state.index = i;
// pr("else state index: "+self.state.index)
return true;
}
......@@ -1182,18 +1176,10 @@ sigma.publicPrototype.startForceAtlas2 = function() {
var V = 10;
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.setAutoSettings();
this.forceatlas2.init();
if(partialGraph.forceatlas2)
pr("t=9: in startfa2 : forceatlas2.active = "+partialGraph.forceatlas2.active)
this.forceatlas2.active=true;
pr("\t\t\t\t\tFA2 Started")
var ene = this._core.graph.nodes.length;
......@@ -1202,12 +1188,6 @@ sigma.publicPrototype.startForceAtlas2 = function() {
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) {
partialGraph.stopForceAtlas2();
return;
......@@ -1220,18 +1200,13 @@ sigma.publicPrototype.startForceAtlas2 = function() {
return true;
});
pr(getClientTime()+"\tjust before addGenerator | fa2.active:"+partialGraph.forceatlas2.active+" | fa2.count: "+partialGraph.forceatlas2.count);
// fixing anomaly in forceatlas2
$.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 ) {
pr("SUPER TECHNIQUE")
pr("SUPER TECHNIQUE!!")
partialGraph.startForceAtlas2();
return;
}
});
}
......
......@@ -1276,9 +1276,7 @@ sigma.classes.Cascade = function() {
if(partialGraph) {
if(partialGraph.forceatlas2) {
pr("t=0: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
partialGraph.stopForceAtlas2();
pr("t=1: in empty graph : forceatlas2.active = "+partialGraph.forceatlas2.active)
}
}
......
......@@ -686,11 +686,10 @@ function extractFromJson(data,seed){
var edgeId = 0;
var edgesNodes = data.edges;
for(var i in edgesNodes) {
//pr(edgesNodes[i]);
var source = edgesNodes[i].s;
var target = edgesNodes[i].t;
var indice=source+";"+target;
// if(indice.indexOf("D::593")!==-1) pr(indice)
var edge = {
id: indice,
sourceID: source,
......@@ -702,98 +701,98 @@ function extractFromJson(data,seed){
if(edge.weight < minEdgeWeight) minEdgeWeight= edge.weight;
if(edge.weight > maxEdgeWeight) maxEdgeWeight= edge.weight;
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"){
// edge.hidden=false;
if(edge.label=="nodes2"){
// edge.hidden=true;
if(isUndef(nodes1[source])) {
nodes1[source] = {
if(isUndef(nodes2[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,
neighbours: []
};
}
if(isUndef(nodes1[target])) {
nodes1[target] = {
if(isUndef(bipartiteN2D[target])) {
bipartiteN2D[target] = {
label: Nodes[target].label,
neighbours: []
};
}
nodes1[source].neighbours.push(target);
nodes1[target].neighbours.push(source);
}
// social edges = 1
Edges[indice].weight = 1;
edge.weight = 1;
bipartiteD2N[source].neighbours.push(target);
bipartiteN2D[target].neighbours.push(source);
partialGraph.addEdge(indice,source,target,edge);
}
if(edge.label=="nodes2"){
// edge.hidden=true;
// // Source is NGram
} else {
if(isUndef(nodes2[source])) {
nodes2[source] = {
if(isUndef(bipartiteN2D[source])) {
bipartiteN2D[source] = {
label: Nodes[source].label,
neighbours: []
};
}
if(isUndef(nodes2[target])) {
nodes2[target] = {
if(isUndef(bipartiteD2N[target])) {
bipartiteD2N[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,
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);
}
bipartiteN2D[source].neighbours.push(target);
bipartiteD2N[target].neighbours.push(source);
}
}
//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