Commit 98bf373c authored by Romain Loth's avatar Romain Loth

better sliders skeleton for bipartite case

faster NodeWeightFilter with the new index, harmonized calls and signatures for nodes and edges functions, TODO check lastFilter updating
parent 0c101924
...@@ -184,9 +184,8 @@ ...@@ -184,9 +184,8 @@
</a></li> </a></li>
<li><a> <li><a>
<!-- TODO fix: category0 -> category1 switching -->
Label size<br> Label size<br>
<div id="slidercat0nodessize" class="settingslider"></div> <div id="sliderlabelsize" class="settingslider"></div>
</a></li> </a></li>
<li class="dropdown"> <li class="dropdown">
...@@ -205,10 +204,8 @@ ...@@ -205,10 +204,8 @@
</li> </li>
--> -->
<!-- TODO fix: category0 -> category1 switching --> <li class="weight-selectors category0">
<li class="weight-selectors"> <!-- Create a subgraph over nodes from TW.categories[0] (docs or def nodes)-->
<!-- <a> -->
<!-- Create a subgraph -->
<table> <table>
<tr> <tr>
<td class="slider-legend"> <td class="slider-legend">
...@@ -226,7 +223,8 @@ ...@@ -226,7 +223,8 @@
</tr> </tr>
</table> </table>
</li> </li>
<!-- <li class="weight-selectors"> <li class="weight-selectors category1">
<!-- Create a subgraph over nodes from TW.categories[1] (terms)-->
<table> <table>
<tr class="weight-selector"> <tr class="weight-selector">
<td class="slider-legend"> <td class="slider-legend">
...@@ -243,7 +241,7 @@ ...@@ -243,7 +241,7 @@
</td> </td>
</tr> </tr>
</table> </table>
</li> --> </li>
</ul> </ul>
......
...@@ -224,7 +224,9 @@ html, body { ...@@ -224,7 +224,9 @@ html, body {
box-shadow: 0px 2px 6px #000; box-shadow: 0px 2px 6px #000;
} }
.category1 {
display: none; /* initial display off but turned on when changetype */
}
.grey { .grey {
color: #cccccc; font-style: italic; color: #cccccc; font-style: italic;
......
...@@ -364,42 +364,45 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -364,42 +364,45 @@ TinaWebJS = function ( sigmacanvas ) {
return this.edgesArray.length; return this.edgesArray.length;
}); });
// register an index for nodes by size (<= origNode.size||origiNode.weight) // register an index for nodes by type and size (<= origNode.size||origNode.weight)
sigmaModule.classes.graph.addIndex('nodesBySize', { sigmaModule.classes.graph.addIndex('nodesBySize', {
constructor: function() { constructor: function() {
this.nodesBySize = {}; this.nodesBySize = {};
}, },
addNode: function(n) { addNode: function(n) {
if (n.size) { if (n.type && n.size) {
let sizekey = parseFloat(n.size) let sizekey = parseFloat(n.size)
if (!this.nodesBySize[sizekey]) if (!this.nodesBySize[n.type])
this.nodesBySize[sizekey] = {} this.nodesBySize[n.type] = {}
this.nodesBySize[sizekey][n.id] = true if (!this.nodesBySize[n.type][sizekey])
this.nodesBySize[n.type][sizekey] = {}
this.nodesBySize[n.type][sizekey][n.id] = true
} }
}, },
dropNode: function(n) { dropNode: function(n) {
if (n.size) { if (n.type && n.size) {
delete(this.nodesBySize[n.size][n.id]) delete(this.nodesBySize[n.type][n.size][n.id])
} }
} }
}); });
// @ntype: a node type from TW.categories
// @aSizeSelector can be: // @aSizeSelector can be:
// - a numeric value // - a numeric value
// - a range (ordered array of 2 numeric values) // - a range (ordered array of 2 numeric values)
sigmaModule.classes.graph.addMethod('getNodesBySize', function(aSizeSelector) { sigmaModule.classes.graph.addMethod('getNodesBySize', function(ntype, aSizeSelector) {
let res = [] let res = []
// shortcut case for commodity: entire index if no arg // shortcut case for commodity: entire index if no arg
if (isUndef(aSizeSelector)) { if (isUndef(aSizeSelector)) {
res = this.nodesBySize res = this.nodesBySize[ntype]
} }
// normal cases // normal cases
else if (isNumeric(aSizeSelector)) { else if (isNumeric(aSizeSelector)) {
let sizekey = parseFloat(aSizeSelector) let sizekey = parseFloat(aSizeSelector)
if (this.nodesBySize[sizekey]) { if (this.nodesBySize[ntype][sizekey]) {
res = Object.keys(this.nodesBySize[sizekey]) res = Object.keys(this.nodesBySize[ntype][sizekey])
} }
} }
else if (Array.isArray(aSizeSelector) else if (Array.isArray(aSizeSelector)
...@@ -411,7 +414,7 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -411,7 +414,7 @@ TinaWebJS = function ( sigmacanvas ) {
let sizeMax = parseFloat(aSizeSelector[1]) let sizeMax = parseFloat(aSizeSelector[1])
// the available sizes // the available sizes
let sortedSizes = Object.keys(this.nodesBySize).sort(function(a,b){return a-b}) let sortedSizes = Object.keys(this.nodesBySize[ntype]).sort(function(a,b){return a-b})
// the nodes with sizes in range // the nodes with sizes in range
for (var k in sortedSizes) { for (var k in sortedSizes) {
...@@ -420,7 +423,7 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -420,7 +423,7 @@ TinaWebJS = function ( sigmacanvas ) {
break break
} }
if (val >= sizeMin) { if (val >= sizeMin) {
res = res.concat(Object.keys(this.nodesBySize[val])) res = res.concat(Object.keys(this.nodesBySize[ntype][val]))
} }
} }
} }
...@@ -457,7 +460,7 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -457,7 +460,7 @@ TinaWebJS = function ( sigmacanvas ) {
// - additionnaly supports 'active/forcelabel' node property (magnify x 3) // - additionnaly supports 'active/forcelabel' node property (magnify x 3)
sigmaModule.canvas.hovers.def = tempo.twRender.canvas.hovers.largerall sigmaModule.canvas.hovers.def = tempo.twRender.canvas.hovers.largerall
console.log('tw renderers registered in sigma module"') console.log('tw renderers registered in sigma module')
} }
this.SearchListeners = function () { this.SearchListeners = function () {
...@@ -725,6 +728,8 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -725,6 +728,8 @@ TinaWebJS = function ( sigmacanvas ) {
} }
}); });
// £TODO test if still needed
pushSWClick("social"); pushSWClick("social");
cancelSelection(false); cancelSelection(false);
...@@ -965,18 +970,25 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -965,18 +970,25 @@ TinaWebJS = function ( sigmacanvas ) {
if (TW.filterSliders) { if (TW.filterSliders) {
NodeWeightFilter ( categories , "#slidercat0nodesweight" , categories[0], "type" ,"size"); // args: for display: target div ,
// for context: family/type prop value,
EdgeWeightFilter("#slidercat0edgesweight", "label" , "nodes1", "weight"); // for values: the property to filter
NodeWeightFilter ( "#slidercat0nodesweight" ,
categories[0] ,
"size"
);
EdgeWeightFilter("#slidercat0edgesweight",
getCurrentTypeString(),
"weight"
);
} }
$("#category1").hide(); $("#category1").hide();
//finished //finished
var labelSizeTimeout = null var labelSizeTimeout = null
$("#slidercat0nodessize").freshslider({ $("#sliderlabelsize").freshslider({
step:.5, step:.5,
min:0, min:0,
max:5, max:5,
......
...@@ -461,68 +461,66 @@ function changeLevel() { ...@@ -461,68 +461,66 @@ function changeLevel() {
//=========================== < FILTERS-SLIDERS > ===========================// //=========================== < FILTERS-SLIDERS > ===========================//
// Execution modes:
// EdgeWeightFilter("#sliderAEdgeWeight", "label" , "nodes1", "weight");
// EdgeWeightFilter("#sliderBEdgeWeight", "label" , "nodes2", "weight");
// NB new sigma js: dropEdge is quite slow so we add a waiting cursor // census of edges by type and by size
// (replaces deprecated AlgorithmForSliders, but without the sqrt transform)
function edgeSizesLookup() {
var edgeweis = {}
function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) { for (let i in TW.edgeIds) {
console.log("EdgeWeightFilter") let e = TW.partialGraph.graph.edges(TW.edgeIds[i])
console.log("sliderDivID", sliderDivID) if (e) {
console.log("type_attrb", type_attrb) if (!edgeweis[e.categ]) edgeweis[e.categ] = {}
console.log("type", type) if (!edgeweis[e.categ][e.weight]) edgeweis[e.categ][e.weight] = []
console.log("criteria", criteria)
// if ($(sliderDivID).html()!="") { edgeweis[e.categ][e.weight].push(e.id)
// console.log("\t\t\t\t\t\t[[ algorithm not applied "+sliderDivID+" ]]")
// return;
// }
// sliderDivID = "#sliderAEdgeWeight"
// type = "nodes1"
// type_attrb = "label"
// criteria = "weight"
// sliderDivID = "#sliderBNodeSize"
// type = "NGram"
// type_attrb = "type"
// criteria = "size"
if(TW.nEdges<3) {
$(sliderDivID).freshslider({
range: true,
step:1,
value:[10, 60],
enabled: false,
onchange:function(low, high){
console.log(low, high);
} }
});
return;
} }
return edgeweis
}
var filterparams = AlgorithmForSliders ( TW.Edges , type_attrb , type , criteria) //OK function edgeSizesSteps(eTypeStr) {
let esizesCensus = edgeSizesLookup()
var stepToIdsArray = []
// TODO make an index
console.log("EdgeWeightFilter: "+type)
console.log(filterparams)
if (esizesCensus[eTypeStr]) {
var sortedSizes = Object.keys(
esizesCensus[eTypeStr]
).sort(function(a,b){return a-b})
var steps = filterparams["steps"] for (let l in sortedSizes) {
stepToIdsArray.push(esizesCensus[eTypeStr][sortedSizes[l]])
}
}
var finalarray = filterparams["finalarray"] return stepToIdsArray
// if(steps<3) { }
// $(sliderDivID).freshslider({
// range: true,
// step:1, // Execution modes:
// value:[10, 60], // EdgeWeightFilter("#sliderAEdgeWeight", "1", "weight");
// enabled: false, // EdgeWeightFilter("#sliderAEdgeWeight", "1|0", "weight");
// onchange:function(low, high){ // EdgeWeightFilter("#sliderBEdgeWeight", "0|1", "weight");
// console.log(low, high);
// } // NB new sigma js: dropEdge is quite slow so we add a waiting cursor
// });
// return; function EdgeWeightFilter(sliderDivID , typestr , criteria) {
// } if(TW.partialGraph.graph.nEdges()<2) {
console.warn('not enough edges for subsets: skipping GUI slider init')
showDisabledSlider(sliderDivID)
return;
}
var stepToIdsArr = edgeSizesSteps(typestr)
var steps = stepToIdsArr.length
if(steps<2) {
console.warn('no size steps for edges: skipping GUI slider init')
showDisabledSlider(sliderDivID)
return;
}
var lastvalue=("0-"+(steps-1)); var lastvalue=("0-"+(steps-1));
...@@ -531,17 +529,21 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) { ...@@ -531,17 +529,21 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) {
var present = TW.partialGraph.states.slice(-1)[0]; var present = TW.partialGraph.states.slice(-1)[0];
console.log('init freshslider for edges, steps:', steps) // console.log('init freshslider for edges, steps:', steps, sliderDivID)
var edgeSlideTimeout = null var edgeSlideTimeout = null
if (steps == 0) {
return
}
//finished //finished
$(sliderDivID).freshslider({ $(sliderDivID).freshslider({
range: true, range: true,
step: 1, step: 1,
min:0, min:0,
bgcolor: (type=="nodes1")?"#27c470":"#FFA500" , // green for docs, orange for terms
bgcolor: (typestr=="1|0" || typestr=="1")?"#27c470":"#FFA500" ,
max:steps-1, max:steps-1,
value:[0,steps-1], value:[0,steps-1],
onchange:function(low, high) { onchange:function(low, high) {
...@@ -564,7 +566,7 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) { ...@@ -564,7 +566,7 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) {
if(filtervalue!=lastFilter[sliderDivID]["last"]) { if(filtervalue!=lastFilter[sliderDivID]["last"]) {
// TODO memoize the last filter value // £TODO better memoize the last filter value
// $.doTimeout(sliderDivID+"_"+lastFilter[sliderDivID]["last"]); // $.doTimeout(sliderDivID+"_"+lastFilter[sliderDivID]["last"]);
...@@ -611,11 +613,11 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) { ...@@ -611,11 +613,11 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) {
// do the important stuff // do the important stuff
// ex iterarr [0:0, 1:1...] // ex iterarr [0:0, 1:1...]
// ex finalarray [0: [eid1,eid2], 1:[eid3,eid4,eid5]...] // ex stepToIdsArr [0: [eid1,eid2], 1:[eid3,eid4,eid5]...]
for( var c in iterarr ) { for( var c in iterarr ) {
var i = iterarr[c]; var i = iterarr[c];
var eids = finalarray[i] var eids = stepToIdsArr[i]
if(i>=low && i<=high) { if(i>=low && i<=high) {
if(addflag) { if(addflag) {
...@@ -635,7 +637,7 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) { ...@@ -635,7 +637,7 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) {
// local level case // local level case
// finalarray is full of edges that don't really exist at this point // stepToIdsArr is full of edges that don't really exist at this point
else { else {
// NB we assume the sigma convention eid = "nid1;nid2" // NB we assume the sigma convention eid = "nid1;nid2"
...@@ -696,15 +698,17 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) { ...@@ -696,15 +698,17 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) {
// console.log("\t\tedgesfilter:") // console.log("\t\tedgesfilter:")
// console.log("\t\t[ Starting FA2 ]") // console.log("\t\t[ Starting FA2 ]")
// [ Starting FA2 ] // [ Starting FA2 ]
setTimeout(function() {
if (!TW.partialGraph.isForceAtlas2Running()) if (!TW.partialGraph.isForceAtlas2Running()
&& TW.partialGraph.graph.nNodes() > 8) {
TW.partialGraph.startForceAtlas2(); TW.partialGraph.startForceAtlas2();
setTimeout(function(){ setTimeout(function(){
if (TW.partialGraph.isForceAtlas2Running()) if (TW.partialGraph.isForceAtlas2Running())
TW.partialGraph.stopForceAtlas2(); TW.partialGraph.stopForceAtlas2();
}, },
3000); 2000) // shorter FA2 sufficient
}
}, 10)
// [ / Starting FA2 ] // [ / Starting FA2 ]
lastvalue = filtervalue; lastvalue = filtervalue;
...@@ -729,63 +733,39 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) { ...@@ -729,63 +733,39 @@ function EdgeWeightFilter(sliderDivID , type_attrb , type , criteria) {
// Execution modes: // Execution modes:
// NodeWeightFilter ( "#sliderANodeWeight" , "Document" , "type" , "size") // NodeWeightFilter ( "#sliderANodeWeight" , "Document" , "size")
// NodeWeightFilter ( "#sliderBNodeWeight" , "NGram" , "type" , "size") // NodeWeightFilter ( "#sliderBNodeWeight" , "NGram" , "size")
function NodeWeightFilter( categories , sliderDivID , type_attrb , type , criteria) { function NodeWeightFilter( sliderDivID , tgtNodeType , criteria) {
// if ($(sliderDivID).html()!="") {
// console.log("\t\t\t\t\t\t[[ algorithm not applied "+sliderDivID+" ]]")
// return;
// }
// sliderDivID = "#sliderAEdgeWeight"
// type = "nodes1"
// type_attrb = "label"
// criteria = "weight"
// sliderDivID = "#sliderBNodeSize"
// type = "NGram"
// type_attrb = "type"
// criteria = "size"
if(TW.partialGraph.graph.nNodes() < 3) {
$(sliderDivID).freshslider({
range: true,
step:1,
value:[10, 60],
enabled: false,
onchange:function(low, high){
console.log(low, high);
}
});
if(TW.partialGraph.graph.nNodes() < 2) {
console.warn('not enough nodes for subsets: skipping GUI slider init')
showDisabledSlider(sliderDivID)
return; return;
} }
// ids per weight level // ids per weight level
// we use live index from prepareSigmaCustomIndices // we use live index from prepareSigmaCustomIndices
let nodesBySize = TW.partialGraph.graph.getNodesBySize() let nodesBySize = TW.partialGraph.graph.getNodesBySize(tgtNodeType)
var sortedSizes = Object.keys(nodesBySize).sort(function(a,b){return a-b}) var sortedSizes = Object.keys(nodesBySize).sort(function(a,b){return a-b})
var steps = sortedSizes.length var stepToIdsArr = []
var finalarray = []
for (let l in sortedSizes) { for (let l in sortedSizes) {
finalarray.push(TW.partialGraph.graph.getNodesBySize(sortedSizes[l]))
var nidsWithThatSize = TW.partialGraph.graph.getNodesBySize(tgtNodeType, sortedSizes[l])
if (nidsWithThatSize.length) {
stepToIdsArr.push(nidsWithThatSize)
} }
}
var steps = stepToIdsArr.length
// console.warn('NodeWeightFilter: steps', steps) // console.warn('NodeWeightFilter: steps', steps)
if(steps<3) { if(steps<2) {
$(sliderDivID).freshslider({ console.warn('no size steps for nodes: skipping GUI slider init')
range: true, showDisabledSlider(sliderDivID)
step:1,
value:[10, 60],
enabled: false,
onchange:function(low, high){
console.log(low, high);
}
});
return; return;
} }
...@@ -797,7 +777,7 @@ function NodeWeightFilter( categories , sliderDivID , type_attrb , type , crit ...@@ -797,7 +777,7 @@ function NodeWeightFilter( categories , sliderDivID , type_attrb , type , crit
step: 1, step: 1,
min:0, min:0,
max:steps-1, max:steps-1,
bgcolor:( type_attrb==categories[0] )?"#27c470":"#FFA500" , bgcolor:( tgtNodeType==TW.categories[0] )?"#27c470":"#FFA500" ,
value:[0,steps-1], value:[0,steps-1],
onchange:function(low, high){ onchange:function(low, high){
var filtervalue = low+"-"+high var filtervalue = low+"-"+high
...@@ -822,8 +802,8 @@ function NodeWeightFilter( categories , sliderDivID , type_attrb , type , crit ...@@ -822,8 +802,8 @@ function NodeWeightFilter( categories , sliderDivID , type_attrb , type , crit
// scheduled: graph rm nodes // scheduled: graph rm nodes
nodeSlideTimeout = setTimeout ( function () { nodeSlideTimeout = setTimeout ( function () {
for(var i in finalarray) { for(var i in stepToIdsArr) {
ids = finalarray[i] ids = stepToIdsArr[i]
if(i>=low && i<=high){ if(i>=low && i<=high){
for(var id in ids) { for(var id in ids) {
ID = ids[id] ID = ids[id]
...@@ -846,15 +826,18 @@ function NodeWeightFilter( categories , sliderDivID , type_attrb , type , crit ...@@ -846,15 +826,18 @@ function NodeWeightFilter( categories , sliderDivID , type_attrb , type , crit
// [ Starting FA2 ] // [ Starting FA2 ]
setTimeout(function() { setTimeout(function() {
if (!TW.partialGraph.isForceAtlas2Running()) if (!TW.partialGraph.isForceAtlas2Running()
TW.partialGraph.startForceAtlas2() && TW.partialGraph.graph.nNodes() > 8) {
// duration = settings_explorerjs.fa2milliseconds TW.partialGraph.startForceAtlas2();
setTimeout(function() { setTimeout(function(){
if (TW.partialGraph.isForceAtlas2Running()) if (TW.partialGraph.isForceAtlas2Running())
TW.partialGraph.stopForceAtlas2() TW.partialGraph.stopForceAtlas2();
}, parseInt(fa2milliseconds) || 5000) },
2000) // shorter FA2 sufficient
}
}, 10) }, 10)
// [ / Starting FA2 ] // [ / Starting FA2 ]
}, 300) }, 300)
} }
...@@ -862,113 +845,18 @@ function NodeWeightFilter( categories , sliderDivID , type_attrb , type , crit ...@@ -862,113 +845,18 @@ function NodeWeightFilter( categories , sliderDivID , type_attrb , type , crit
}); });
} }
// new sigma.js nodesIndex and edgesIndex are private attributes so we use getters function showDisabledSlider(someDivId) {
function getGraphElement(elemId) { $(someDivId).freshslider({
if(elemId.split(";").length==1) return TW.partialGraph.graph.nodes(elemId); range: true,
else return TW.partialGraph.graph.edges(elemId) step:1,
} min: 0,
max: 1,
value:[0, 1],
// creates graph subsets enabled: false
// ---------------------
// TODO use a type-based index for elems subset
// TODO use a size/weight-based index for elem_attrb
// 4 Execution modes:
// AlgorithmForSliders ( TW.partialGraph._core.graph.edges , "label" , "nodes1" , "weight")
// AlgorithmForSliders ( TW.partialGraph._core.graph.edges , "label" , "nodes2" , "weight")
// AlgorithmForSliders ( TW.partialGraph._core.graph.nodes , "type" , "Document" , "size")
// AlgorithmForSliders ( TW.partialGraph._core.graph.nodes , "type" , "NGram" , "size")
function AlgorithmForSliders( elements , type_attrb , type , criteria) {
// // ( 1 )
// // get visible sigma nodes|edges
if(isUndef(elements)) return {"steps":0 , "finalarray":[]};
var elems = [];
for(var e in elements) {
if( elements[e][type_attrb]==type ) {
if(getGraphElement(e)) {
elems.push(elements[e])
}
}
}
if(elems.length==0)
return { "steps":0 , "finalarray":[] };
// identifying if you received nodes or edges
var edgeflag = (elems[0].id.split(";").length>1);
console.log("AlgorithmForSliders edgeflag", edgeflag)
// // ( 2 )
// // extract [ "edgeID" : edgeWEIGHT ] | [ "nodeID" : nodeSIZE ]
// // and save this into edges_weight | nodes_size
var elem_attrb=[]
for (var i in elems) {
e = elems[i]
id = e.id
elem_attrb[id]=e[criteria]
// console.log(id+"\t:\t"+e[criteria])
}
// console.log("{ id : size|weight } ")
// console.log(elem_attrb)
// // ( 3 )
// // order dict edges_weight by edge weight | nodes_size by node size
var result = ArraySortByValue(elem_attrb, function(a,b){
return a-b
//ASCENDENT
}); });
// console.log(result.length) $(someDivId).css('cursor', 'not-allowed')
// // ( 4 )
// // printing ordered ASC by weigth
// for (var i in result) {
// r = result[i]
// idid = r.key
// elemattrb = r.value
// console.log(idid+"\t:\t"+elemattrb)
// // e = result[i]
// // console.log(e[criteria])
// }
var N = result.length
// var magnitude = (""+N).length //order of magnitude of edges|nodes
// var exponent = magnitude - 1
// var steps = Math.pow(10,exponent) // #(10 ^ magnit-1) steps
// var stepsize = Math.round(N/steps)// ~~(visibledges / #steps)
//var roundsqrtN = Math.round( Math.sqrt( N ) );
var steps = Math.round( Math.sqrt( N ) );
var stepsize = Math.round( N / steps );
// console.log("-----------------------------------")
// console.log("number of visible nodes|edges: "+N);
// console.log("number of steps : "+steps)
// console.log("size of one step : "+stepsize)
// console.log("-----------------------------------")
var finalarray = []
var counter=0
for(var i = 0; i < steps*2; i++) {
// console.log(i)
var IDs = []
for(var j = 0; j < stepsize; j++) {
if(!isUndef(result[counter])) {
k = result[counter].key
// w = result[counter].value
// console.log("\t["+counter+"] : "+w)
IDs.push(k)
}
counter++;
}
if(IDs.length==0) break;
finalarray[i] = IDs
}
// console.log("finalarray: ")
return {"steps":finalarray.length,"finalarray":finalarray}
} }
//=========================== </ FILTERS-SLIDERS > ===========================// //=========================== </ FILTERS-SLIDERS > ===========================//
......
...@@ -368,11 +368,6 @@ else { ...@@ -368,11 +368,6 @@ else {
console.error("== currently unhandled categorization of node types ==", TW.categories) console.error("== currently unhandled categorization of node types ==", TW.categories)
} }
for(var i in TW.categories) {
TW.Filters[i] = {}
TW.Filters[i]["#slidercat"+i+"edgesweight"] = true;
}
// [ Initiating Sigma-Canvas ] // [ Initiating Sigma-Canvas ]
// POSS: ideally this should take a TW.settings as parameter // POSS: ideally this should take a TW.settings as parameter
...@@ -508,6 +503,10 @@ else { ...@@ -508,6 +503,10 @@ else {
// here 'type' means: the categorie(s) that is (are) currently displayed // here 'type' means: the categorie(s) that is (are) currently displayed
TW.partialGraph.states[1].type = initialState; TW.partialGraph.states[1].type = initialState;
TW.partialGraph.states[1].LouvainFait = false; TW.partialGraph.states[1].LouvainFait = false;
// by default category0 is the initial type
$(".category1").hide();
// [ / Poblating the Sigma-Graph ] // [ / Poblating the Sigma-Graph ]
...@@ -570,51 +569,38 @@ else { ...@@ -570,51 +569,38 @@ else {
if (TW.filterSliders) { if (TW.filterSliders) {
// £TODO test with comex2
if(typestring=="0|1") {
$("#category0").hide();
$("#category1").show();
if($("#slidercat1nodesweight").html()=="") // recreate sliders after perimeter changes
NodeWeightFilter( this.categories , "#slidercat1nodesweight" , this.categories[1], "type" ,"size"); // £TODO fix conditions (was if #slider.html == '' or if level changed)
// atm on any state change
if($("#slidercat1edgesweight").html()=="") // terms
EdgeWeightFilter("#slidercat1edgesweight", "label" , "nodes2", "weight"); if(typestring=="0|1") {
$(".category0").hide();
$(".category1").show();
if(present.level!=past.level) { NodeWeightFilter( "#slidercat1nodesweight" , TW.categories[1], "size");
NodeWeightFilter( this.categories , "#slidercat1nodesweight" , this.categories[1], "type" ,"size"); EdgeWeightFilter("#slidercat1edgesweight", typestring, "weight");
EdgeWeightFilter("#slidercat1edgesweight", "label" , "nodes2", "weight");
}
set_ClustersLegend ( "clust_default" )
} }
// docs
if(typestring=="1|0") { if(typestring=="1|0") {
$("#category0").show(); $(".category0").show();
$("#category1").hide(); $(".category1").hide();
if($("#slidercat0nodesweight").html()=="")
NodeWeightFilter( this.categories , "#slidercat0nodesweight" , this.categories[0], "type" ,"size");
if($("#slidercat0edgesweight").html()=="") NodeWeightFilter( "#slidercat0nodesweight" , TW.categories[0], "size");
EdgeWeightFilter("#slidercat0edgesweight", "label" , "nodes1", "weight"); EdgeWeightFilter("#slidercat0edgesweight", typestring, "weight");
if(present.level!=past.level) {
NodeWeightFilter( this.categories , "#slidercat0nodesweight" , this.categories[0], "type" ,"size");
EdgeWeightFilter("#slidercat0edgesweight", "label" , "nodes1", "weight");
}
set_ClustersLegend ( "clust_default" )
} }
// terms and docs
if(typestring=="1|1") { if(typestring=="1|1") {
$("#category0").show(); $(".category0").show();
$("#category1").show(); $(".category1").show();
// if(present.level!=past.level) { NodeWeightFilter( "#slidercat0nodesweight" , TW.categories[0], "size");
NodeWeightFilter ( this.categories , "#slidercat0nodesweight" , this.categories[0], "type" ,"size"); NodeWeightFilter( "#slidercat1nodesweight" , TW.categories[1], "size");
EdgeWeightFilter("#slidercat0edgesweight", "label" , "nodes1", "weight"); EdgeWeightFilter("#slidercat0edgesweight", "1|0", "weight");
NodeWeightFilter( this.categories , "#slidercat1nodesweight" , this.categories[1], "type" ,"size"); EdgeWeightFilter("#slidercat1edgesweight", "0|1", "weight");
EdgeWeightFilter("#slidercat1edgesweight", "label" , "nodes2", "weight");
// }
} }
} }
...@@ -628,10 +614,6 @@ else { ...@@ -628,10 +614,6 @@ else {
for (var k in filterEls) { for (var k in filterEls) {
if (filterEls[k] && filterEls[k].style) filterEls[k].style.display="none" if (filterEls[k] && filterEls[k].style) filterEls[k].style.display="none"
} }
// document.getElementById('slidercat0nodesweight').style.display="none"
// document.getElementById('slidercat0edgesweight').style.display="none"
// document.getElementById('slidercat1nodesweight').style.display="none"
// document.getElementById('slidercat1edgesweight').style.display="none"
} }
TW.FA2Params = { TW.FA2Params = {
...@@ -688,6 +670,8 @@ else { ...@@ -688,6 +670,8 @@ else {
); );
} }
// adapt the enviroment to monopartite vs. bipartite cases
if( TW.categories.length==1 ) { if( TW.categories.length==1 ) {
$("#changetype").hide(); $("#changetype").hide();
$("#taboppos").remove(); $("#taboppos").remove();
......
...@@ -106,6 +106,12 @@ function getCurrentType() { ...@@ -106,6 +106,12 @@ function getCurrentType() {
return currentTypes.join('-') return currentTypes.join('-')
} }
function getCurrentTypeString() {
let lastState = TW.partialGraph.states.slice(-1)[0]
return lastState.type.map(Number).join('|')
}
function highlightSelectedNodes(flag){ function highlightSelectedNodes(flag){
console.log("\t***methods.js:highlightSelectedNodes(flag)"+flag+" selEmpty:"+is_empty(selections)) console.log("\t***methods.js:highlightSelectedNodes(flag)"+flag+" selEmpty:"+is_empty(selections))
...@@ -201,8 +207,8 @@ function RefreshState(newNOW){ ...@@ -201,8 +207,8 @@ function RefreshState(newNOW){
$("#semLoader").hide(); $("#semLoader").hide();
$("#category-B").show(); $("#category-B").show();
setTimeout(function(){ setTimeout(function(){
EdgeWeightFilter("#sliderBEdgeWeight", "label" , "nodes2", "weight"); EdgeWeightFilter("#sliderBEdgeWeight", "0|1", "weight");
NodeWeightFilter ( "#sliderBNodeWeight" , "NGram", "type" , "size"); NodeWeightFilter ( "#sliderBNodeWeight" , "NGram", "size");
},30) },30)
} else { } else {
$("#semLoader").css('visibility', 'visible'); $("#semLoader").css('visibility', 'visible');
......
...@@ -948,7 +948,7 @@ function dictfyJSON( data , categories ) { ...@@ -948,7 +948,7 @@ function dictfyJSON( data , categories ) {
let typestring = findEdgeType(nodes, source, target) let typestring = findEdgeType(nodes, source, target)
// save edge property // save edge "type" in categ property
edge.categ = typestring edge.categ = typestring
TW.Relations = updateRelations( TW.Relations, TW.Relations = updateRelations( TW.Relations,
typestring, typestring,
......
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