Commit 4822b693 authored by Romain Loth's avatar Romain Loth

Remove deprecated methods from graphExplorer code

parent 46599baf
......@@ -184,219 +184,6 @@ 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);
opossites = [];
selections = [];
partialGraph.refresh();
}
if((typeof selections[currentNode.id])=="undefined"){
selections[currentNode.id] = 1;
currentNode.active=true;
}
else {
delete selections[currentNode.id];
currentNode.active=false;
}
//highlightOpossites(nodes1[currentNode.id].neighbours);
// currentNode.color = currentNode.attr['true_color'];
// currentNode.attr['grey'] = 0;
//
//
partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.8);
partialGraph.refresh();
}
// it receives entire node
function selection(currentNode){
console.log('FUN t.methods:selection')
if(checkBox==false && cursor_size==0) {
highlightSelectedNodes(false);
opossites = [];
selections = [];
partialGraph.refresh();
}
if(socsemFlag==false){
if(isUndef(selections[currentNode.id])){
selections[currentNode.id] = 1;
if(Nodes[currentNode.id].type==catSoc && !isUndef(bipartiteD2N[currentNode.id])){
for(i=0;i<bipartiteD2N[currentNode.id].neighbours.length;i++) {
if(isUndef(opossites[bipartiteD2N[currentNode.id].neighbours[i]])){
opossites[bipartiteD2N[currentNode.id].neighbours[i]]=1;
}
else {
opossites[bipartiteD2N[currentNode.id].neighbours[i]]++;
}
}
}
if(Nodes[currentNode.id].type==catSem){
if(!isUndef(bipartiteN2D[currentNode.id])){
for(i=0;i<bipartiteN2D[currentNode.id].neighbours.length;i++) {
if(isUndef(opossites[bipartiteN2D[currentNode.id].neighbours[i]])){
opossites[bipartiteN2D[currentNode.id].neighbours[i]]=1;
}
else opossites[bipartiteN2D[currentNode.id].neighbours[i]]++;
}
}
}
currentNode.active=true;
}
else {
delete selections[currentNode.id];
markAsSelected(currentNode.id,false);
if(Nodes[currentNode.id].type==catSoc){
for(i=0;i<bipartiteD2N[currentNode.id].neighbours.length;i++) {
if(isUndef(opossites[bipartiteD2N[currentNode.id].neighbours[i]])) {
console.log("lala");
}
if(opossites[bipartiteD2N[currentNode.id].neighbours[i]]==1){
delete opossites[bipartiteD2N[currentNode.id].neighbours[i]];
}
if(opossites[bipartiteD2N[currentNode.id].neighbours[i]]>1){
opossites[bipartiteD2N[currentNode.id].neighbours[i]]--;
}
}
}
if(Nodes[currentNode.id].type==catSem){
for(i=0;i<bipartiteN2D[currentNode.id].neighbours.length;i++) {
if(isUndef(opossites[bipartiteN2D[currentNode.id].neighbours[i]])) {
console.log("lala");
}
if(opossites[bipartiteN2D[currentNode.id].neighbours[i]]==1){
delete opossites[bipartiteN2D[currentNode.id].neighbours[i]];
}
if(opossites[bipartiteN2D[currentNode.id].neighbours[i]]>1){
opossites[bipartiteN2D[currentNode.id].neighbours[i]]--;
}
}
}
currentNode.active=false;
}
}
/* ============================================================================================== */
else {
if(isUndef(selections[currentNode.id])){
selections[currentNode.id] = 1;
if(Nodes[currentNode.id].type==catSoc){
for(i=0;i<bipartiteD2N[currentNode.id].neighbours.length;i++) {
//opossitesbipartiteD2N[currentNode.id].neighbours[i]];
if(isUndef(opossites[bipartiteD2N[currentNode.id].neighbours[i].toString()])){
opossites[bipartiteD2N[currentNode.id].neighbours[i]]=1;
}
else {
opossites[bipartiteD2N[currentNode.id].neighbours[i]]++;
}
}
}
if(Nodes[currentNode.id].type==catSem){
for(i=0;i<nodes2[currentNode.id].neighbours.length;i++) {
if(isUndef(opossites[nodes2[currentNode.id].neighbours[i]])){
opossites[nodes2[currentNode.id].neighbours[i]]=1;
}
else opossites[nodes2[currentNode.id].neighbours[i]]++;
}
}
currentNode.active=true;
}
else {
delete selections[currentNode.id];
markAsSelected(currentNode.id,false);
if(Nodes[currentNode.id].type==catSoc){
for(i=0;i<bipartiteD2N[currentNode.id].neighbours.length;i++) {
if(isUndef(opossites[bipartiteD2N[currentNode.id].neighbours[i]])) {
console.log("lala");
}
if(opossites[bipartiteD2N[currentNode.id].neighbours[i]]==1){
delete opossites[bipartiteD2N[currentNode.id].neighbours[i]];
}
if(opossites[bipartiteD2N[currentNode.id].neighbours[i]]>1){
opossites[bipartiteD2N[currentNode.id].neighbours[i]]--;
}
}
}
if(Nodes[currentNode.id].type==catSem){
for(i=0;i<nodes2[currentNode.id].neighbours.length;i++) {
if(isUndef(opossites[nodes2[currentNode.id].neighbours[i]])) {
console.log("lala");
}
if(opossites[nodes2[currentNode.id].neighbours[i]]==1){
delete opossites[nodes2[currentNode.id].neighbours[i]];
}
if(opossites[nodes2[currentNode.id].neighbours[i]]>1){
opossites[nodes2[currentNode.id].neighbours[i]]--;
}
}
}
currentNode.active=false;
}
}
// partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.8);
partialGraph.refresh();
}
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];
if(socsemFlag==true) {
pr("wtf is this -> if(socsemFlag==true) {");
cancelSelection(false);
socsemFlag=false;
}
if (!node) return null;
//selection(node);
if(categoriesIndex.length==1) selectionUni(node);
if(categoriesIndex.length==2) selection(node);
opos = ArraySortByValue(opossites, function(a,b){
return b-a
});
}
// tag cloud div
function htmlfied_alternodes(elems) {
console.log('FUN t.methods:htmlfied_alternodes')
var oppositesNodes=[]
js1='onclick="graphTagCloudElem(\'';
js2="');\""
frecMAX=elems[0].value
for(var i in elems){
id=elems[i].key
frec=elems[i].value
if(frecMAX==1) fontSize=desirableTagCloudFont_MIN;
else {
fontSize=
desirableTagCloudFont_MIN+
(frec-1)*
((desirableTagCloudFont_MAX-desirableTagCloudFont_MIN)/(frecMAX-1));
}
if(!isUndef(Nodes[id])){
// js1 js2
// onclick="graphTagCloudElem(' ');
htmlfied_alternode = '<span class="tagcloud-item" style="font-size:'+fontSize+'px;" '+js1+id+js2+'>'+ Nodes[id].label+ '</span>';
oppositesNodes.push(htmlfied_alternode)
}
}
return oppositesNodes
}
function manualForceLabel(nodeid,active) {
console.log('FUN t.methods:manualForceLabel')
......@@ -723,479 +510,8 @@ function greyEverything(){
eds[i].attr['grey'] = 1;
}
// deselect neighbours of previous selection i think
// for(var i in selections){
// if(!isUndef(nodes1[i])){
// if(!isUndef(nodes1[i]["neighbours"])){
// nb=nodes1[i]["neighbours"];
// for(var j in nb){
// deselections[nb[j]]=1;
// partialGraph._core.graph.nodesIndex[nb[j]].forceLabel=true;
// partialGraph._core.graph.nodesIndex[nb[j]].neighbour=true;
// }
// }
// }
// }
}
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];
nodeSel.color = nodeSel.attr['true_color'];
nodeSel.attr['grey'] = 0;
nodeSel.active = true;
var typeNow = partialGraph.states.type.map(Number).join("|");
neigh = Relations[typeNow][s]
if(neigh) {
for(var i in neigh){
vec = partialGraph._core.graph.nodesIndex[neigh[i]];
if(vec) {
vec.color = vec.attr['true_color'];
vec.attr['grey'] = 0;
an_edge=partialGraph._core.graph.edgesIndex[vec.id+";"+nodeSel.id];
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
an_edge=partialGraph._core.graph.edgesIndex[nodeSel.id+";"+vec.id];
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
}
}
}
// if( !isUndef(nodes1[nodeSel.id]) && !isUndef(nodes1[nodeSel.id].neighbours) ){
// neigh=nodes1[nodeSel.id].neighbours;/**/
// for(var i in neigh){
// vec = partialGraph._core.graph.nodesIndex[neigh[i]];
// if(vec) {
// vec.color = vec.attr['true_color'];
// vec.attr['grey'] = 0;
// an_edge=partialGraph._core.graph.edgesIndex[vec.id+";"+nodeSel.id];
// if(!isUndef(an_edge) && !an_edge.hidden){
// an_edge.color = an_edge.attr['true_color'];
// an_edge.attr['grey'] = 0;
// }
// an_edge=partialGraph._core.graph.edgesIndex[nodeSel.id+";"+vec.id];
// if(!isUndef(an_edge) && !an_edge.hidden){
// an_edge.color = an_edge.attr['true_color'];
// an_edge.attr['grey'] = 0;
// }
// }
// }
// }
}
//to_del
//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];
if(sel) {
nodeSel.color = nodeSel.attr['true_color'];
nodeSel.attr['grey'] = 0;
if(categoriesIndex.length==1) {
if( !isUndef(nodes1[nodeSel.id]) &&
!isUndef(nodes1[nodeSel.id].neighbours)
){
neigh=nodes1[nodeSel.id].neighbours;/**/
for(var i in neigh){
vec = partialGraph._core.graph.nodesIndex[neigh[i]];
if(vec) {
vec.color = vec.attr['true_color'];
vec.attr['grey'] = 0;
an_edge=partialGraph._core.graph.edgesIndex[vec.id+";"+nodeSel.id];
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
an_edge=partialGraph._core.graph.edgesIndex[nodeSel.id+";"+vec.id];
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
}
}
}
} // two categories network:
else {
if(swclickActual=="social") {
if(nodeSel.type==catSoc){
if( !isUndef(nodes1[nodeSel.id]) &&
!isUndef(nodes1[nodeSel.id].neighbours)
){
neigh=nodes1[nodeSel.id].neighbours;/**/
for(var i in neigh) {
if( !isUndef(partialGraph._core.graph.nodesIndex[neigh[i]]) ) {
nodeVec = partialGraph._core.graph.nodesIndex[neigh[i]];
// vec.color = vec.attr['true_color'];
// vec.attr['grey'] = 0;
// pr("nodeselected: "+nodeSel.id+"\t"+nodeSel.label+"\t\t||\t\tvecino: "+vec.id+"\t"+vec.label)
possibledge1 = partialGraph._core.graph.edgesIndex[nodeVec.id+";"+nodeSel.id]
possibledge2 = partialGraph._core.graph.edgesIndex[nodeSel.id+";"+nodeVec.id]
an_edge = (!isUndef(possibledge1))?possibledge1:possibledge2;
if(!isUndef(an_edge) && !an_edge.hidden) {
//highlight node
// nodeVec.hidden = false;
nodeVec.color = nodeVec.attr['true_color'];
nodeVec.attr['grey'] = 0;
//highlight edge
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
// if ( (NOW=="a" || NOW=="b") && nodeVec.color==grey)
// pr(nodeVec)
// nodeVec.hidden = true
// an_edge=partialGraph._core.graph.edgesIndex[vec.id+";"+nodeSel.id];
// if(!isUndef(an_edge) && !an_edge.hidden){
// an_edge.color = an_edge.attr['true_color'];
// an_edge.attr['grey'] = 0;
// }
// an_edge=partialGraph._core.graph.edgesIndex[nodeSel.id+";"+vec.id];
// if(!isUndef(an_edge) && !an_edge.hidden){
// an_edge.color = an_edge.attr['true_color'];
// an_edge.attr['grey'] = 0;
// }
}
}
}
} else {
if( !isUndef(bipartiteN2D[nodeSel.id]) &&
!isUndef(bipartiteN2D[nodeSel.id].neighbours)
){
neigh=bipartiteN2D[nodeSel.id].neighbours;/**/
for(var i in neigh){
if( !isUndef(partialGraph._core.graph.nodesIndex[neigh[i]]) ){
vec = partialGraph._core.graph.nodesIndex[neigh[i]];
vec.color = vec.attr['true_color'];
vec.attr['grey'] = 0;
an_edge=partialGraph._core.graph.edgesIndex[vec.id+";"+nodeSel.id];
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
an_edge=partialGraph._core.graph.edgesIndex[nodeSel.id+";"+vec.id];
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
}
}
}
}
}
if(swclickActual=="semantic") {
if(nodeSel.type==catSoc){
if( !isUndef(bipartiteD2N[nodeSel.id]) &&
!isUndef(bipartiteD2N[nodeSel.id].neighbours)
){
neigh=bipartiteD2N[nodeSel.id].neighbours;/**/
for(var i in neigh) {
if( !isUndef(partialGraph._core.graph.nodesIndex[neigh[i]]) ) {
vec = partialGraph._core.graph.nodesIndex[neigh[i]];
vec.color = vec.attr['true_color'];
vec.attr['grey'] = 0;
an_edge=partialGraph._core.graph.edgesIndex[vec.id+";"+nodeSel.id];
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
an_edge=partialGraph._core.graph.edgesIndex[nodeSel.id+";"+vec.id];
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
}
}
}
}
else {
if( !isUndef(nodes2[nodeSel.id]) &&
!isUndef(nodes2[nodeSel.id].neighbours)
){
neigh=nodes2[nodeSel.id].neighbours;/**/
for(var i in neigh){
if( !isUndef(partialGraph._core.graph.nodesIndex[neigh[i]]) ) {
nodeVec = partialGraph._core.graph.nodesIndex[neigh[i]];
// vec.color = vec.attr['true_color'];
// vec.attr['grey'] = 0;
// pr("nodeselected: "+nodeSel.id+"\t"+nodeSel.label+"\t\t||\t\tvecino: "+vec.id+"\t"+vec.label)
possibledge1 = partialGraph._core.graph.edgesIndex[nodeVec.id+";"+nodeSel.id]
possibledge2 = partialGraph._core.graph.edgesIndex[nodeSel.id+";"+nodeVec.id]
an_edge = (!isUndef(possibledge1))?possibledge1:possibledge2;
if(!isUndef(an_edge) && !an_edge.hidden) {
//highlight node
// nodeVec.hidden = false;
nodeVec.color = nodeVec.attr['true_color'];
nodeVec.attr['grey'] = 0;
//highlight edge
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
// if ( (NOW=="a" || NOW=="b") && nodeVec.color==grey)
// pr(nodeVec)
// nodeVec.hidden = true
// vec = partialGraph._core.graph.nodesIndex[neigh[i]];
// vec.color = vec.attr['true_color'];
// vec.attr['grey'] = 0;
// an_edge=partialGraph._core.graph.edgesIndex[vec.id+";"+nodeSel.id];
// if(!isUndef(an_edge) && !an_edge.hidden){
// an_edge.color = an_edge.attr['true_color'];
// an_edge.attr['grey'] = 0;
// }
// an_edge=partialGraph._core.graph.edgesIndex[nodeSel.id+";"+vec.id];
// if(!isUndef(an_edge) && !an_edge.hidden){
// an_edge.color = an_edge.attr['true_color'];
// an_edge.attr['grey'] = 0;
// }
}
}
}
}
}
if(swclickActual=="sociosemantic") {
if(nodeSel.type==catSoc){
if( !isUndef(nodes1[nodeSel.id]) &&
!isUndef(nodes1[nodeSel.id].neighbours)
){
neigh=nodes1[nodeSel.id].neighbours;/**/
for(var i in neigh){
if( !isUndef(partialGraph._core.graph.nodesIndex[neigh[i]]) ) {
vec = partialGraph._core.graph.nodesIndex[neigh[i]];
vec.color = vec.attr['true_color'];
vec.attr['grey'] = 0;
an_edge=partialGraph._core.graph.edgesIndex[vec.id+";"+nodeSel.id];
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
an_edge=partialGraph._core.graph.edgesIndex[nodeSel.id+";"+vec.id];
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
}
}
}
if( !isUndef(bipartiteD2N[nodeSel.id]) &&
!isUndef(bipartiteD2N[nodeSel.id].neighbours)
){
neigh=bipartiteD2N[nodeSel.id].neighbours;/**/
for(var i in neigh) {
if( !isUndef(partialGraph._core.graph.nodesIndex[neigh[i]]) ) {
vec = partialGraph._core.graph.nodesIndex[neigh[i]];
vec.color = vec.attr['true_color'];
vec.attr['grey'] = 0;
an_edge=partialGraph._core.graph.edgesIndex[vec.id+";"+nodeSel.id];
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
an_edge=partialGraph._core.graph.edgesIndex[nodeSel.id+";"+vec.id];
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
}
}
}
}
else {
if( !isUndef(nodes2[nodeSel.id]) &&
!isUndef(nodes2[nodeSel.id].neighbours)
){
neigh=nodes2[nodeSel.id].neighbours;/**/
for(var i in neigh) {
if( !isUndef(partialGraph._core.graph.nodesIndex[neigh[i]]) ) {
vec = partialGraph._core.graph.nodesIndex[neigh[i]];
vec.color = vec.attr['true_color'];
vec.attr['grey'] = 0;
an_edge=partialGraph._core.graph.edgesIndex[vec.id+";"+nodeSel.id];
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
an_edge=partialGraph._core.graph.edgesIndex[nodeSel.id+";"+vec.id];
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
}
}
}
if( !isUndef(bipartiteN2D[nodeSel.id]) &&
!isUndef(bipartiteN2D[nodeSel.id].neighbours)
){
neigh=bipartiteN2D[nodeSel.id].neighbours;/**/
for(var i in neigh){
if( !isUndef(partialGraph._core.graph.nodesIndex[neigh[i]]) ) {
vec = partialGraph._core.graph.nodesIndex[neigh[i]];
vec.color = vec.attr['true_color'];
vec.attr['grey'] = 0;
an_edge=partialGraph._core.graph.edgesIndex[vec.id+";"+nodeSel.id];
if(!isUndef(an_edge) && !an_edge.hidden){
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
an_edge=partialGraph._core.graph.edgesIndex[nodeSel.id+";"+vec.id];
if(!isUndef(an_edge) && !an_edge.hidden) {
an_edge.color = an_edge.attr['true_color'];
an_edge.attr['grey'] = 0;
}
}
}
}
}
}
}
}
}
//to_del
function DrawAsSelectedNodes( nodeskeys ) {
console.log('FUN t.methods:DrawAsSelectedNodes')
greyEverything();
var ndsids=[]
if( $.isArray(nodeskeys) ) {
if(nodeskeys.length==0 && !is_empty(nodeskeys))
ndsids = Object.keys(nodeskeys)
else
ndsids=nodeskeys;
} else ndsids.push(nodeskeys);
if(!checkBox) {
checkBox=true;
for(var i in ndsids){
nodeid = ndsids[i]
markAsSelected(nodeid,true);
}
checkBox=false;
}
overNodes=true;
}
//to_del
function MultipleSelection(nodes , desalg){
console.log('FUN t.methods:MultipleSelection')
pr("IN MULTIPLE SELECTION: checkbox="+checkBox)
var prevsels = selections;
if(!checkBox) cancelSelection(false);
greyEverything();
var ndsids=[]
if(! $.isArray(nodes)) ndsids.push(nodes);
else ndsids=nodes;
if(!checkBox) {
checkBox=true;
printStates();
pr("prevsels:")
pr(Object.keys(prevsels))
pr("ndsids:")
pr(ndsids)
if (desalg && !is_empty(prevsels) ) {
pr("DOING THE WEIRD ALGORITHM")
var blacklist = {};
for(var i in ndsids) {
ID = ndsids[i];
if ( prevsels[ID] ) {
delete prevsels[ID];
blacklist[ID] = true;
}
}
if(Object.keys(blacklist).length>0) {
tmparr = Object.keys(prevsels);
for (var i in ndsids) {
ID = ndsids[i];
if(isUndef(blacklist[ID])) {
tmparr.push(ID)
}
}
ndsids = tmparr;
}
} else pr("CASE NOT COVERED")
if (ndsids.length>0) {
for(var i in ndsids) {
nodeid = ndsids[i]
getOpossitesNodes(nodeid,false); //false -> just nodeid
markAsSelected(nodeid,true);
}
} else {
cancelSelection(false);
partialGraph.draw();
RefreshState("")
checkBox=false;
return;
}
checkBox=false;
} else {
//checkbox = true
cancelSelection(false);
greyEverything();
for(var i in ndsids){
nodeid = ndsids[i]
getOpossitesNodes(nodeid,false); //false -> just nodeid
markAsSelected(nodeid,true);
}
}
overNodes=true;
partialGraph.draw();
updateLeftPanel_fix();
RefreshState("")
}
function graphResetColor(){
......@@ -1220,153 +536,6 @@ 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"
existingNodes = partialGraph._core.graph.nodes;
if( categoriesIndex.length==1 ) {
var pairdict = {}
for(var n in existingNodes) {
ID = existingNodes[n].id;
vois = nodes1[ID].neighbours;
for(var v in vois) {
pair = [ parseInt(ID) , parseInt(vois[v]) ].sort(compareNumbers)
pairdict [ pair[0]+";"+pair[1] ] = 1
}
}
for (var e in pairdict) {
edge = "";
if(isUndef(Edges[e])) {
E = e.split(";")
edge = E[1]+";"+E[0];
} else edge=e;
E = edge.split(";")
if( getn(E[0]) && getn(E[1]) )
unHide(edge)
// pr("antes:"+e+"\t|\tdespues:"+edge)
// pr("\t\t\t\t\t----- decision final "+edge)
// unHide(edge)
}
return;
}
if(typeOfNodes=="Bipartite"){
for(i=0; i < existingNodes.length ; i++){
for(j=0; j < existingNodes.length ; j++){
i1=existingNodes[i].id+";"+existingNodes[j].id;
i2=existingNodes[j].id+";"+existingNodes[i].id;
indexS1 = existingNodes[i].id;
indexT1 = existingNodes[j].id;
indexS2 = existingNodes[j].id;
indexT2 = existingNodes[i].id;
if(!isUndef(Edges[i1]) && !isUndef(Edges[i2])){
if(Edges[i1].weight > Edges[i2].weight ){
unHide(indexS1+";"+indexT1);
}
if(Edges[i1].weight < Edges[i2].weight){
unHide(indexS2+";"+indexT2);
}
if(Edges[i1].weight == Edges[i2].weight){
if(Edges[i1].label!="bipartite") { /*danger*/
if( isUndef(partialGraph._core.graph.edgesIndex[indexS1+";"+indexT1]) &&
isUndef(partialGraph._core.graph.edgesIndex[indexT1+";"+indexS1]) ){
unHide(indexS1+";"+indexT1);
}
}
}
}
else {
if(!isUndef(Edges[i1])){// && Edges[i1].label=="bipartite"){
//I've found a source Node
unHide(indexS1+";"+indexT1);
}
if(!isUndef(Edges[i2])){// && Edges[i2].label=="bipartite"){
//I've found a target Node
unHide(indexS2+";"+indexT2);
}
}
}
}
}
else {
for(i=0; i < existingNodes.length ; i++){
for(j=(i+1); j < existingNodes.length ; j++){
i1=existingNodes[i].id+";"+existingNodes[j].id;
i2=existingNodes[j].id+";"+existingNodes[i].id;
// pr("Edges[i1]:")
// pr(Edges[i1])
// pr("Edges[i2]:")
// pr(Edges[i2])
// pr(".")
// pr(".")
// if(!isUndef(Edges[i1]) && !isUndef(Edges[i2]) && i1!=i2){
// if(typeOfNodes=="Scholars") {
// if(Edges[i1].label=="nodes1" && Edges[i2].label=="nodes1"){
// pr(Edges[i1])
// if(Edges[i1].weight > Edges[i2].weight){
// unHide(i1);
// }
// if(Edges[i1].weight < Edges[i2].weight){
// unHide(i2);
// }
// if(Edges[i1].weight == Edges[i2].weight){
// unHide(i1);
// }
// }
// }
// if(typeOfNodes=="Keywords") {
// if(Edges[i1].label=="nodes2" && Edges[i2].label=="nodes2"){
// pr(Edges[i1]);
// if(Edges[i1].weight > Edges[i2].weight){
// unHide(i1);
// }
// if(Edges[i1].weight < Edges[i2].weight){
// unHide(i2);
// }
// if(Edges[i1].weight == Edges[i2].weight){
// unHide(i1);
// }
// }
// }
// }
// else {
e=(!isUndef(Edges[i1]))?Edges[i1]:Edges[i2]
if(!isUndef(e)){
if(typeOfNodes=="Scholars" && e.label=="nodes1") unHide(e.id)
if(typeOfNodes=="Keywords" && e.label=="nodes2") unHide(e.id)
}
// }
}
}
}
}
function hideEverything(){
console.log('FUN t.methods:hideEverything')
......@@ -1434,56 +603,6 @@ function add1Elem(id) {
}
}
//to_del
function unHide(id){
console.log('FUN t.methods:unHide')
// pr("unhide "+id)
id = ""+id;
if(id.split(";").length==1) {
// i've received a NODE
if(!isUndef(getn(id))) return;
if(Nodes[id]) {
var tt = Nodes[id].type
var anode = ({
id:id,
label: Nodes[id].label,
size: (parseFloat(Nodes[id].size)+sizeMult[tt])+"",
x: Nodes[id].x,
y: Nodes[id].y,
hidden: (Nodes[id].lock)?true:false,
type: Nodes[id].type,
color: Nodes[id].color,
shape: Nodes[id].shape
}); // The graph node
if(!Nodes[id].lock) {
updateSearchLabels(id,Nodes[id].label,Nodes[id].type);
nodeslength++;
}
partialGraph.addNode(id,anode);
return;
}
}
else {// It's an edge!
//visibleEdges.push(id);
if(!isUndef(gete(id))) return;
if(Edges[id] && !Edges[id].lock){
var anedge = {
id: id,
sourceID: Edges[id].sourceID,
targetID: Edges[id].targetID,
lock : false,
label: Edges[id].label,
weight: (swMacro && (iwantograph=="sociosemantic"))?Edges[id].bweight:Edges[id].weight
};
partialGraph.addEdge(id , anedge.sourceID , anedge.targetID , anedge);
return;
}
}
}
function pushFilterValue(filtername,arg){
console.log('FUN t.methods:pushFilterValue')
......@@ -1497,452 +616,6 @@ 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
var edge = {
id: ID,
sourceID: s,
targetID: t,
label: Edges[ID].label,
weight: Edges[ID].weight,
hidden : false
};
if(getn(s) && getn(t)) {
partialGraph.addEdge(ID,s,t,edge);
if(!isUndef(getn(s))) {
partialGraph._core.graph.nodesIndex[s].x = Nodes[s].x
partialGraph._core.graph.nodesIndex[s].y = Nodes[s].y
}
if(!isUndef(getn(t))) {
partialGraph._core.graph.nodesIndex[t].x = Nodes[t].x
partialGraph._core.graph.nodesIndex[t].y = Nodes[t].y
}
}
}
//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;
}
else {// It's an edge!
partialGraph._core.graph.edgesIndex[id].hidden=true;
// partialGraph._core.graph.edgesIndex[id].dead=true;
}
}
//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;
}
else {// It's an edge!
partialGraph._core.graph.edgesIndex[id].hidden=false;
// partialGraph._core.graph.edgesIndex[id].dead=false;
}
}
//to_del
function changeToMeso(iwannagraph) {
console.log('FUN t.methods:changeToMeso')
labels=[]
iwantograph=iwannagraph;//just a mess
partialGraph.emptyGraph();
pr("changing to Meso-"+iwannagraph);
if(iwannagraph=="social") {
if(!is_empty(selections)) {
if(swclickPrev=="social") {
var finalnodes={}
for(var i in selections) {
finalnodes[i]=1
if(nodes1[i]) {
for(var j in nodes1[i].neighbours) {
id=nodes1[i].neighbours[j];
s = i;
t = id;
edg1 = Edges[s+";"+t];
if(edg1){
// pr("\tunhide "+edg1.id)
if(!edg1.lock){
finalnodes[t] = 1;
}
}
edg2 = Edges[t+";"+s];
if(edg2){
// pr("\tunhide "+edg2.id)
if(!edg2.lock){
finalnodes[t] = 1;
}
}
}
}
}
for (var Nk in finalnodes) unHide(Nk);
createEdgesForExistingNodes(iwannagraph);/**/
}
if(swclickPrev=="semantic") {
var finalnodes={}
for(var i in selections) {
if(Nodes[i].type==catSem){
for(var j in opossites) {
// unHide(j);
finalnodes[j] = 1;
}
}
else {
// unHide(i);
finalnodes[i]=1;
if(nodes1[i]) {
neigh=nodes1[i].neighbours;
for(var j in neigh) {
// unHide(neigh[j]);
finalnodes[neigh[j]] = 1;
}
}
}
}
for (var Nk in finalnodes) unHide(Nk);
createEdgesForExistingNodes(iwannagraph);/**/
}
if(swclickPrev=="sociosemantic") {
var finalnodes={}
for(var i in selections) {
if(Nodes[i].type==catSoc){
// unHide(i);
finalnodes[i] = 1;
if(nodes1[i]) {
for(var j in nodes1[i].neighbours) {
id=nodes1[i].neighbours[j];
// unHide(id);
finalnodes[id] = 1;
}
}
// createEdgesForExistingNodes(iwannagraph);
}
if(Nodes[i].type==catSem){
for(var j in opossites) {
// unHide(j);
finalnodes[j] = 1;
}
}
}
for (var Nk in finalnodes) unHide(Nk);
createEdgesForExistingNodes(iwannagraph);
}
}
// EdgeWeightFilter("#sliderAEdgeWeight", "label" , "nodes1", "weight");
$("#colorGraph").show();
}
if(iwannagraph=="sociosemantic") {
if(!is_empty(selections) && !is_empty(opossites)){
for(var i in selections) {
unHide(i);
}
for(var i in opossites) {
unHide(i);
}
createEdgesForExistingNodes(iwannagraph);
socsemFlag=true;
}
$("#category-B").show();
EdgeWeightFilter("#sliderBEdgeWeight", "label" , "nodes2", "weight");
NodeWeightFilter ( "#sliderBNodeWeight" , "NGram", "type" , "size");
$("#colorGraph").hide();
}
if(iwannagraph=="semantic") {
if(!is_empty(opossites)){
// hideEverything()
//pr("2. swclickPrev: "+swclickPrev+" - swclickActual: "+swclickActual);
var finalnodes = {}
if(swclickPrev=="semantic") {
var finalnodes={}
for(var i in selections) {
finalnodes[i]=1
if(nodes2[i]) {
for(var j in nodes2[i].neighbours) {
id=nodes2[i].neighbours[j];
s = i;
t = id;
edg1 = Edges[s+";"+t];
if(edg1){
// pr("\tunhide "+edg1.id)
if(!edg1.lock){
finalnodes[t] = 1;
}
}
edg2 = Edges[t+";"+s];
if(edg2){
// pr("\tunhide "+edg2.id)
if(!edg2.lock){
finalnodes[t] = 1;
}
}
}
}
}
for (var Nk in finalnodes) unHide(Nk);
createEdgesForExistingNodes(iwannagraph);/**/
// for(var i in selections) {
// // unHide(i);
// finalnodes[i] = 1;
// if(nodes2[i]) {
// neigh=nodes2[i].neighbours;
// for(var j in neigh) {
// // unHide(neigh[j]);
// finalnodes[neigh[j]] = 1;
// }
// }
// }
// for (var Nk in finalnodes) unHide(Nk);
// createEdgesForExistingNodes(iwannagraph);
}
if(swclickPrev=="social") {
var finalnodes = {}
for(var i in selections) {
if(Nodes[i].type==catSoc){
for(var j in opossites) {
// unHide(j);
finalnodes[j] = 1;
}
} else {
// unHide(i);
finalnodes[i] = 1;
if(nodes2[i]) {
neigh=nodes2[i].neighbours;
for(var j in neigh) {
// unHide(neigh[j]);
finalnodes[neigh[j]] = 1;
}
}
}
}
for (var Nk in finalnodes) unHide(Nk);
createEdgesForExistingNodes(iwannagraph);
}
if(swclickPrev=="sociosemantic") {
var finalnodes = {}
for(var i in selections) {
if(Nodes[i].type==catSoc){
for(var j in opossites) {
// unHide(j);
finalnodes[i] = 1;
}
}
if(Nodes[i].type==catSem){
// unHide(i);//sneaky bug!
finalnodes[i] = 1;
if(nodes2[i]) {
for(var j in nodes2[i].neighbours) {
id=nodes2[i].neighbours[j];
// unHide(id);
finalnodes[id] = 1;
}
}
}
}
for (var Nk in finalnodes) unHide(Nk);
createEdgesForExistingNodes(iwannagraph);
}
}
$("#category-B").show();
EdgeWeightFilter("#sliderBEdgeWeight", "label" , "nodes2", "weight");
NodeWeightFilter ( "#sliderBNodeWeight" , "NGram", "type" , "size");
// EdgeWeightFilter("#sliderBEdgeWeight", "label" , "nodes2", "weight");
// NodeWeightFilter ( "#sliderBNodeWeight" , "type" , "NGram" , "size")
$("#colorGraph").hide();
}
MultipleSelection(Object.keys(selections) , false);//false-> dont apply deselection algorithm
partialGraph.zoomTo(partialGraph._core.width / 2, partialGraph._core.height / 2, 0.8);
fa2enabled=true; partialGraph.startForceAtlas2();
$('.gradient').css({"background-size":"90px 90px"});
}
//to_del
function changeToMacro(iwannagraph) {
console.log('FUN t.methods:changeToMacro')
labels=[]
pr("CHANGING TO Macro-"+iwannagraph);
iwantograph=iwannagraph;//just a mess
partialGraph.emptyGraph();
if ( iwannagraph=="semantic" && !semanticConverged ) {
partialGraph.draw();
partialGraph.refresh();
$("#semLoader").css('visibility', 'visible');
$("#semLoader").show();
return;
}
//iwantograph Social OR Semantic
if(iwannagraph!="sociosemantic") {
socsemFlag=false;
category = (iwannagraph=="social")?catSoc:catSem;
pr("CHANGING TO Macro-"+iwannagraph+" __ [category: "+category+"] __ [actualsw: "+swclickActual+"] __ [prevsw: "+swclickPrev+"]")
//show semantic nodes
for(var n in Nodes) {
if(Nodes[n].type==category){
unHide(n);
}
} // and semantic edges
createEdgesForExistingNodes(iwannagraph);
if(iwannagraph=="social") showMeSomeLabels(6);
else {
$("#category-B").show();
EdgeWeightFilter("#sliderBEdgeWeight", "label" , "nodes2", "weight");
NodeWeightFilter ( "#sliderBNodeWeight" , "NGram", "type" , "size");
}
swMacro=true;
if (!is_empty(selections))
$.doTimeout(10,function (){
chosenones=(PAST=="a"||PAST=="b")?selections:opossites;
MultipleSelection(Object.keys(chosenones) , false)//false-> dont apply deselection algorithm
});
} else {
//iwantograph socio-semantic
for(var n in Nodes) unHide(n);
for(var e in Edges) {
if(Edges[e].label=="nodes1" || Edges[e].label=="nodes2"){
st=e.split(";");
if(Edges[st[0]+";"+st[1]] && Edges[st[1]+";"+st[0]] &&
Edges[st[0]+";"+st[1]].hidden==true &&
Edges[st[1]+";"+st[0]].hidden==true
){
if(Edges[st[0]+";"+st[1]].weight == Edges[st[1]+";"+st[0]].weight){
unHide(st[0]+";"+st[1]);
}
else {
if(Edges[st[0]+";"+st[1]].weight > Edges[st[1]+";"+st[0]].weight){
unHide(st[0]+";"+st[1]);
}
else {
unHide(st[1]+";"+st[0]);
}
}
}
}
if(Edges[e].label=="bipartite"){
unHide(e);
}
}
if (!is_empty(selections))
MultipleSelection(Object.keys(selections) , false);//false-> dont apply deselection algorithm
}
$.doTimeout(30,function (){
if(iwannagraph=="social") {
// EdgeWeightFilter("#sliderAEdgeWeight", "label" , "nodes1", "weight");
$("#colorGraph").show();
}
if(iwannagraph=="semantic") {
// EdgeWeightFilter("#sliderBEdgeWeight", "label" , "nodes2", "weight");
// NodeWeightFilter ( "#sliderBNodeWeight" , "type" , "NGram" , "size")
$("#colorGraph").hide();
}
if(iwannagraph=="sociosemantic") {
// EdgeWeightFilter("#sliderBEdgeWeight", "label" , "nodes2", "weight");
// NodeWeightFilter ( "#sliderBNodeWeight" , "type" , "NGram" , "size")
// EdgeWeightFilter("#sliderAEdgeWeight", "label" , "nodes1", "weight");
$("#colorGraph").hide();
}
});
// fa2enabled=true; partialGraph.startForceAtlas2();
$('.gradient').css({"background-size":"40px 40px"});
var activefilterscount=0;
for(var i in lastFilter) {
if(iwannagraph=="social" && i.indexOf("sliderA")!=-1 )
if(lastFilter[i].charAt(0)!="0")
activefilterscount++;
if(iwannagraph=="semantic" && i.indexOf("sliderb")!=-1)
if(lastFilter[i].charAt(0)!="0")
activefilterscount++;
if(iwannagraph=="sociosemantic")
if(lastFilter[i].charAt(0)!="0")
activefilterscount++;
}
// for 1 second, activate FA2 if there is any filter applied
if(activefilterscount>0) {
partialGraph.startForceAtlas2();
$.doTimeout(2000,function (){
partialGraph.stopForceAtlas2()
});
}
}
//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;
}
}
}
function saveGraph() {
console.log('FUN t.methods:saveGraph')
......
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