Commit dd2456cc authored by Romain Loth's avatar Romain Loth

mass rename to clarify the active types bool array and its associated str key

this boolean array symbolizes for each node type if yes or no it is displayed, with effet also on edges)... It apparently replaced around 2015 the earlier convention with types A, B, AB... it is often used (symbolizing for each node type if yes or no it is active)... it was sometimes named states (very confusing with the other 'states' that record user interaction steps and that also contain info about these activetypes) or type (misleading singular)
parent 82a36d00
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
</ul> </ul>
</a></li> </a></li>
<li class="weight-selectors category0"> <li class="weight-selectors for-nodecategory-0">
<!-- Create a subgraph over nodes from TW.categories[0] (docs or def nodes)--> <!-- Create a subgraph over nodes from TW.categories[0] (docs or def nodes)-->
<table> <table>
<tr> <tr>
...@@ -215,7 +215,7 @@ ...@@ -215,7 +215,7 @@
</tr> </tr>
</table> </table>
</li> </li>
<li class="weight-selectors category1"> <li class="weight-selectors for-nodecategory-1">
<!-- Create a subgraph over nodes from TW.categories[1] (terms)--> <!-- Create a subgraph over nodes from TW.categories[1] (terms)-->
<table> <table>
<tr class="weight-selector"> <tr class="weight-selector">
......
...@@ -29,7 +29,7 @@ function changeGraphAppearanceByFacets( manualflag ) { ...@@ -29,7 +29,7 @@ function changeGraphAppearanceByFacets( manualflag ) {
// create colormenu // create colormenu
var ty = getCurrentType() var ty = getActivetypesName()
var color_menu_info = '<li><a href="#" onclick="graphResetColor()">By Default</a></li>'; var color_menu_info = '<li><a href="#" onclick="graphResetColor()">By Default</a></li>';
...@@ -144,11 +144,11 @@ function SomeEffect( ValueclassCode ) { ...@@ -144,11 +144,11 @@ function SomeEffect( ValueclassCode ) {
iClu=Number(raw[2]); iClu=Number(raw[2]);
// also get node type code from env (ie "1", "1|1", etc for TW.Relations lookup)
var present = TW.partialGraph.states.slice(-1)[0]; // Last // £TODO factorizable: always the same loop for neighbors this should be handled by a sub of MultipleSelection2
var type_t0 = present.type; // get the active types code from current state (ie "1", "1|1", etc for TW.Relations lookup)
var str_type_t0 = type_t0.map(Number).join("|") var activetypesKey = getActivetypesKey()
// console.log( "\t"+str_type_t0) // console.log( "\t"+activetypesKey)
// we have our precomputed idmaps for nodes_2_colour // we have our precomputed idmaps for nodes_2_colour
// ------------------------------------------------- // -------------------------------------------------
...@@ -167,8 +167,8 @@ function SomeEffect( ValueclassCode ) { ...@@ -167,8 +167,8 @@ function SomeEffect( ValueclassCode ) {
n.customAttrs['highlight'] = true; n.customAttrs['highlight'] = true;
} }
if(TW.Relations[str_type_t0] && TW.Relations[str_type_t0][nid] ) { if(TW.Relations[activetypesKey] && TW.Relations[activetypesKey][nid] ) {
neigh = TW.Relations[str_type_t0][nid] neigh = TW.Relations[activetypesKey][nid]
if(neigh) { if(neigh) {
for(j in neigh) { for(j in neigh) {
tgt_nid = neigh[j] tgt_nid = neigh[j]
...@@ -250,7 +250,7 @@ function set_ClustersLegend ( daclass, groupedByTicks ) { ...@@ -250,7 +250,7 @@ function set_ClustersLegend ( daclass, groupedByTicks ) {
daclass = "louvain" daclass = "louvain"
// usually 'terms' or current display among TW.categories // usually 'terms' or current display among TW.categories
var curType = getCurrentType() var curType = getActivetypesName()
// all infos in a bin array // all infos in a bin array
var legendInfo = [] var legendInfo = []
......
...@@ -38,12 +38,11 @@ var TW = {} ...@@ -38,12 +38,11 @@ var TW = {}
// TODO more generic module integrating the variants cf. experiments/histogramModule_STUB_GENERIQUE // TODO more generic module integrating the variants cf. experiments/histogramModule_STUB_GENERIQUE
TW.DivsFlags["crowdsourcingModule"] = false ; TW.DivsFlags["crowdsourcingModule"] = false ;
TW.SystemStates = {} TW.SystemState = {}
TW.SystemStates.level = true; TW.SystemState.level = true;
// TW.SystemStates.type = [ true ] //[ true , false ]; //social activated! TW.SystemState.type = [ true, false ] // usually overridden by makeSystemStates
TW.SystemStates.type = [ true, false ] //[ true , false ]; //social activated! TW.SystemState.selections = [];
TW.SystemStates.selections = []; TW.SystemState.opposites = [];
TW.SystemStates.opposites = [];
TW.catSoc = "Document"; TW.catSoc = "Document";
TW.catSem = "NGram"; TW.catSem = "NGram";
......
...@@ -168,9 +168,9 @@ function SelectionEngine() { ...@@ -168,9 +168,9 @@ function SelectionEngine() {
// type:[0]} // type:[0]}
var typeNow = TW.partialGraph.states.slice(-1)[0].type.map(Number).join("|") var activetypesKey = getActivetypesKey()
// console.log ("console.loging the Type:") // console.log ("console.loging the Type:")
// console.log (typeNow) // console.log (activetypesKey)
// console.log (" - - - - - - ") // console.log (" - - - - - - ")
// Dictionaries of: selection+neighbors // Dictionaries of: selection+neighbors
...@@ -189,8 +189,8 @@ function SelectionEngine() { ...@@ -189,8 +189,8 @@ function SelectionEngine() {
for(var i in ndsids) { for(var i in ndsids) {
var s = ndsids[i]; var s = ndsids[i];
if(TW.Relations[typeNow] && TW.Relations[typeNow][s] ) { if(TW.Relations[activetypesKey] && TW.Relations[activetypesKey][s] ) {
var neigh = TW.Relations[typeNow][s] var neigh = TW.Relations[activetypesKey][s]
if(neigh) { if(neigh) {
for(var j in neigh) { for(var j in neigh) {
var t = neigh[j] var t = neigh[j]
...@@ -1021,7 +1021,7 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -1021,7 +1021,7 @@ TinaWebJS = function ( sigmacanvas ) {
); );
EdgeWeightFilter("#slidercat0edgesweight", EdgeWeightFilter("#slidercat0edgesweight",
getCurrentTypeString(), getActivetypesKey(),
"weight" "weight"
); );
} }
...@@ -1057,4 +1057,47 @@ TinaWebJS = function ( sigmacanvas ) { ...@@ -1057,4 +1057,47 @@ TinaWebJS = function ( sigmacanvas ) {
cancelSelection(false); cancelSelection(false);
} }
this.initialActivetypes = function( categories ) {
var firstActivetypes = []
for(var i=0; i<categories.length ; i++) {
if(i==0) firstActivetypes.push(true) // <==> show the cat stored in 0
else firstActivetypes.push(false) // <==> hide the cat stored in 1
}
console.debug('firstActivetypes', firstActivetypes)
return firstActivetypes;
}
this.allPossibleActivetypes = function (cats) {
if (TW.debugFlags.logSettings) console.debug(`allPossibleActivetypes(cats=${cats})`)
var possibleActivetypes = {}
var N=Math.pow(2 , cats.length);
for (i = 0; i < N; i++) {
let bin = (i).toString(2)
let bin_splitted = []
for(var j in bin)
bin_splitted.push(bin[j])
let bin_array = [];
let toadd = cats.length-bin_splitted.length;
for (var k = 0; k < toadd; k++)
bin_array.push("0")
for(var j in bin)
bin_array.push(bin[j])
bin_array = bin_array.map(Number)
let sum = bin_array.reduce(function(a, b){return a+b;})
if( sum != 0 && sum < 3) {
let id = bin_array.join("|")
possibleActivetypes[id] = bin_array.map(Boolean)
}
}
return possibleActivetypes;
}
}; };
...@@ -84,8 +84,8 @@ function changeType() { ...@@ -84,8 +84,8 @@ function changeType() {
var level = present.level; var level = present.level;
var sels = present.selections var sels = present.selections
var type_t0 = present.type; var t0Activetypes = present.activetypes;
var str_type_t0 = type_t0.map(Number).join("|") var t0ActivetypesKey = t0Activetypes.map(Number).join("|")
console.debug("CHANGE TYPE, present.selections", present.selections) console.debug("CHANGE TYPE, present.selections", present.selections)
...@@ -96,32 +96,32 @@ function changeType() { ...@@ -96,32 +96,32 @@ function changeType() {
// type "grammar" // type "grammar"
// used to distinguish types in TW.Relations // used to distinguish types in TW.Relations
// types eg [true] <=> '1' // activetypes eg [true] <=> key '1'
// [true, true] <=> '1|1' // [true, true] <=> key '1|1'
// [true, false] <=> '1|0' // [true, false] <=> key '1|0'
// Complement of the received state ~[X\Y] ) // Complement of the received state ~[X\Y] )
var type_t1 = [] var t1Activetypes = []
for(var i in type_t0) type_t1[i] = !type_t0[i] for(var i in t0Activetypes) t1Activetypes[i] = !t0Activetypes[i]
var str_type_t1 = type_t1.map(Number).join("|") var t1ActivetypesKey = t1Activetypes.map(Number).join("|")
var binSumCats = [] var binSumCats = []
for(var i in type_t0) for(var i in t0Activetypes)
binSumCats[i] = (type_t0[i]||type_t1[i]) binSumCats[i] = (t0Activetypes[i]||t1Activetypes[i])
var str_binSumCats = binSumCats.map(Number).join("|") var str_binSumCats = binSumCats.map(Number).join("|")
var nextState = [] var nextState = []
if(level) nextState = type_t1; if(level) nextState = t1Activetypes;
else nextState = binSumCats; else nextState = binSumCats;
if(!level && past!=false) { if(!level && past!=false) {
var sum_past = present.type.map(Number).reduce(function(a, b){return a+b;}) var sum_past = present.activetypes.map(Number).reduce(function(a, b){return a+b;})
console.log("sum_past:") console.log("sum_past:")
console.log(sum_past) console.log(sum_past)
console.log("past.type:") console.log("past.activetypes:")
console.log(past.type) console.log(past.activetypes)
if(sum_past>1) { if(sum_past>1) {
nextState = past.type; nextState = past.activetypes;
} }
} }
var str_nextState = nextState.map(Number).join("|") var str_nextState = nextState.map(Number).join("|")
...@@ -161,32 +161,32 @@ function changeType() { ...@@ -161,32 +161,32 @@ function changeType() {
if(present.level) { //If level=Global, fill all {X}-component if(present.level) { //If level=Global, fill all {X}-component
for(var nid in TW.Nodes) { for(var nid in TW.Nodes) {
if(type_t1[TW.catDict[TW.Nodes[nid].type]]) { if(t1Activetypes[TW.catDict[TW.Nodes[nid].type]]) {
add1Elem(nid) add1Elem(nid)
} }
} }
for(var eid in TW.Edges) { for(var eid in TW.Edges) {
if(TW.Edges[eid].categ==str_type_t1) if(TW.Edges[eid].categ==t1ActivetypesKey)
add1Elem(eid) add1Elem(eid)
} }
} else /* Local level, change to previous or alter component*/ { } else /* Local level, change to previous or alter component*/ {
if(sels.length==0) { if(sels.length==0) {
console.log(" * * * * * * * * * * * * * * ") console.log(" * * * * * * * * * * * * * * ")
console.log("the past: ") console.log("the past: ")
console.log(past.type.map(Number)+" , "+past.level) console.log(past.activetypes.map(Number)+" , "+past.level)
console.log(past) console.log(past)
console.log("the present: ") console.log("the present: ")
console.log(present.type.map(Number)+" , "+present.level) console.log(present.activetypes.map(Number)+" , "+present.level)
console.log(present) console.log(present)
console.log("str_type_t0: "+str_type_t0) console.log("t0ActivetypesKey: "+t0ActivetypesKey)
console.log("str_type_t1: "+str_type_t1) console.log("t1ActivetypesKey: "+t1ActivetypesKey)
console.log("str_nextState: "+str_nextState) console.log("str_nextState: "+str_nextState)
var newsels = {} var newsels = {}
var sumpastcat = type_t0.map(Number).reduce(function(a, b){return a+b;}) var sumpastcat = t0Activetypes.map(Number).reduce(function(a, b){return a+b;})
if(sumpastcat==1) /* change to alter comp*/ { if(sumpastcat==1) /* change to alter comp*/ {
for(var i in prevnodes) { for(var i in prevnodes) {
s = i; s = i;
...@@ -201,7 +201,7 @@ function changeType() { ...@@ -201,7 +201,7 @@ function changeType() {
for(var i in nodes_2_colour) { for(var i in nodes_2_colour) {
s = i; s = i;
neigh = TW.Relations[str_type_t1][s] neigh = TW.Relations[t1ActivetypesKey][s]
if(neigh) { if(neigh) {
for(var j in neigh) { for(var j in neigh) {
t = neigh[j] t = neigh[j]
...@@ -219,7 +219,7 @@ function changeType() { ...@@ -219,7 +219,7 @@ function changeType() {
for(var eid in edges_2_colour) for(var eid in edges_2_colour)
add1Elem(eid) add1Elem(eid)
nextState = type_t1; nextState = t1Activetypes;
} }
...@@ -236,19 +236,19 @@ function changeType() { ...@@ -236,19 +236,19 @@ function changeType() {
// console.log(sels) // console.log(sels)
// Defining the new selection (if it's necessary) // Defining the new selection (if it's necessary)
var sumCats = type_t0.map(Number).reduce(function(a, b){return a+b;}) var sumCats = t0Activetypes.map(Number).reduce(function(a, b){return a+b;})
var sumFutureCats = nextState.map(Number).reduce(function(a, b){return a+b;}) var sumFutureCats = nextState.map(Number).reduce(function(a, b){return a+b;})
nextState = (sumFutureCats==2 && !level && sumCats==1 )? nextState : type_t1; nextState = (sumFutureCats==2 && !level && sumCats==1 )? nextState : t1Activetypes;
if(str_type_t1=="0|0" ) nextState=past.type; if(t1ActivetypesKey=="0|0" ) nextState=past.activetypes;
// nextState = ( past.type && !level && sumCats==1 )? past.type : type_t1; // nextState = ( past.activetypes && !level && sumCats==1 )? past.activetypes : t1Activetypes;
str_nextState = nextState.map(Number).join("|") str_nextState = nextState.map(Number).join("|")
var sumNextState = nextState.map(Number).reduce(function(a, b){return a+b;}) var sumNextState = nextState.map(Number).reduce(function(a, b){return a+b;})
// [ ChangeType: incremental selection ] // [ ChangeType: incremental selection ]
if(sumCats==1 && sumNextState<2) { if(sumCats==1 && sumNextState<2) {
var indexCat = str_binSumCats;//(level)? str_type_t1 : str_binSumCats ; var indexCat = str_binSumCats;//(level)? t1ActivetypesKey : str_binSumCats ;
// Dictionaries of: opposite-neighs of current selection // Dictionaries of: opposite-neighs of current selection
var newsels = {} var newsels = {}
for(var i in sels) { for(var i in sels) {
...@@ -334,11 +334,11 @@ function changeType() { ...@@ -334,11 +334,11 @@ function changeType() {
TW.partialGraph.states[avantlastpos].LouvainFait = false; TW.partialGraph.states[avantlastpos].LouvainFait = false;
TW.partialGraph.states[avantlastpos].level = present.level; TW.partialGraph.states[avantlastpos].level = present.level;
TW.partialGraph.states[avantlastpos].selections = selsbackup; TW.partialGraph.states[avantlastpos].selections = selsbackup;
TW.partialGraph.states[avantlastpos].type = present.type; TW.partialGraph.states[avantlastpos].activetypes = present.activetypes;
TW.partialGraph.states[avantlastpos].opposites = present.opposites; TW.partialGraph.states[avantlastpos].opposites = present.opposites;
TW.partialGraph.states[lastpos].setState({ TW.partialGraph.states[lastpos].setState({
type: nextState, activetypes: nextState,
level: level, level: level,
sels: Object.keys(selections), sels: Object.keys(selections),
oppos: [] oppos: []
...@@ -389,13 +389,13 @@ function changeLevel() { ...@@ -389,13 +389,13 @@ function changeLevel() {
// types eg [true] <=> '1' // types eg [true] <=> '1'
// [true, true] <=> '1|1' // [true, true] <=> '1|1'
var type_t0 = present.type; var t0Activetypes = present.activetypes;
var str_type_t0 = type_t0.map(Number).join("|") var t0ActivetypesKey = t0Activetypes.map(Number).join("|")
// [X|Y]-change (NOT operation over the received state [X\Y] ) // [X|Y]-change (NOT operation over the received state [X\Y] )
var type_t1 = [] var t1Activetypes = []
for(var i in type_t0) type_t1[i] = !type_t0[i] for(var i in t0Activetypes) t1Activetypes[i] = !t0Activetypes[i]
var str_type_t1 = type_t1.map(Number).join("|") var t1ActivetypesKey = t1Activetypes.map(Number).join("|")
TW.partialGraph.graph.clear(); TW.partialGraph.graph.clear();
...@@ -407,7 +407,7 @@ function changeLevel() { ...@@ -407,7 +407,7 @@ function changeLevel() {
// POSS: factorize with same strategy in MultipleSelection2 beginning // POSS: factorize with same strategy in MultipleSelection2 beginning
for(var i in sels) { for(var i in sels) {
s = sels[i]; s = sels[i];
neigh = TW.Relations[str_type_t0][s] neigh = TW.Relations[t0ActivetypesKey][s]
if(neigh) { if(neigh) {
for(var j in neigh) { for(var j in neigh) {
t = neigh[j] t = neigh[j]
...@@ -452,12 +452,12 @@ function changeLevel() { ...@@ -452,12 +452,12 @@ function changeLevel() {
// var t0 = performance.now() // var t0 = performance.now()
for(var nid in TW.Nodes) { for(var nid in TW.Nodes) {
if(type_t0[TW.catDict[TW.Nodes[nid].type]]) if(t0Activetypes[TW.catDict[TW.Nodes[nid].type]])
// we add 1 by 1 // we add 1 by 1
add1Elem(nid) add1Elem(nid)
} }
for(var eid in TW.Edges) { for(var eid in TW.Edges) {
if(TW.Edges[eid].categ==str_type_t0) if(TW.Edges[eid].categ==t0ActivetypesKey)
add1Elem(eid) add1Elem(eid)
} }
...@@ -484,11 +484,11 @@ function changeLevel() { ...@@ -484,11 +484,11 @@ function changeLevel() {
TW.partialGraph.states[avantlastpos] = {}; TW.partialGraph.states[avantlastpos] = {};
TW.partialGraph.states[avantlastpos].level = present.level; TW.partialGraph.states[avantlastpos].level = present.level;
TW.partialGraph.states[avantlastpos].selections = present.selections; TW.partialGraph.states[avantlastpos].selections = present.selections;
TW.partialGraph.states[avantlastpos].type = present.type; TW.partialGraph.states[avantlastpos].activetypes = present.activetypes;
TW.partialGraph.states[avantlastpos].opposites = present.opposites; TW.partialGraph.states[avantlastpos].opposites = present.opposites;
TW.partialGraph.states[lastpos].setState({ TW.partialGraph.states[lastpos].setState({
type: present.type, activetypes: present.activetypes,
level: futurelevel, level: futurelevel,
sels: Object.keys(selections), sels: Object.keys(selections),
oppos: [] oppos: []
......
...@@ -398,8 +398,10 @@ function mainStartGraph(inFormat, inData, twInstance) { ...@@ -398,8 +398,10 @@ function mainStartGraph(inFormat, inData, twInstance) {
TW.categories = [] TW.categories = []
TW.catDict = {} TW.catDict = {}
} }
var possibleStates = makeSystemStates( TW.categories )
var initialState = buildInitialState( TW.categories ) //[true,false]// // possible typestates as a child of scenario states
var possibleActivetypes = TW.instance.allPossibleActivetypes( TW.categories )
var initialActivetypes = TW.instance.initialActivetypes( TW.categories ) //[true,false]//
// XML parsing from ParseCustom // XML parsing from ParseCustom
var dicts = start.makeDicts(TW.categories); // > parse json or gexf, dictfy var dicts = start.makeDicts(TW.categories); // > parse json or gexf, dictfy
...@@ -468,13 +470,13 @@ function mainStartGraph(inFormat, inData, twInstance) { ...@@ -468,13 +470,13 @@ function mainStartGraph(inFormat, inData, twInstance) {
// NB new sigma.js: autoResize (no need for AdjustSigmaCanvas + sigmaLimits) // NB new sigma.js: autoResize (no need for AdjustSigmaCanvas + sigmaLimits)
// console.log("categories: "+categories) // console.log("categories: "+categories)
// console.log("initial state: "+initialState) // console.log("initial types: "+initialTypes)
// [ Poblating the Sigma-Graph ] // [ Poblating the Sigma-Graph ]
// preparing the data and settings // preparing the data and settings
TW.graphData = {nodes: [], edges: []} TW.graphData = {nodes: [], edges: []}
TW.graphData = sigma_utils.FillGraph( initialState , TW.catDict , TW.Nodes , TW.Edges , TW.graphData ); TW.graphData = sigma_utils.FillGraph( initialActivetypes , TW.catDict , TW.Nodes , TW.Edges , TW.graphData );
// // ----------- TEST stock parse gexf and use nodes to replace TW's --------- // // ----------- TEST stock parse gexf and use nodes to replace TW's ---------
...@@ -579,37 +581,43 @@ function mainStartGraph(inFormat, inData, twInstance) { ...@@ -579,37 +581,43 @@ function mainStartGraph(inFormat, inData, twInstance) {
// POSS make it TW.states // POSS make it TW.states
TW.partialGraph.states = [] TW.partialGraph.states = []
TW.partialGraph.states[0] = false; TW.partialGraph.states[0] = false;
TW.partialGraph.states[1] = TW.SystemStates;
// can be COMMENTED OUT: in specifications categories never change so states shouldn't need them // from settings_explorer (everything except the type)
// TW.partialGraph.states[1].categories = TW.categories TW.partialGraph.states[1] = TW.SystemState
// TW.partialGraph.states[1].categoriesDict = TW.catDict;
// here 'type' means: the categorie(s) that is (are) currently displayed // activetypes: the node categorie(s) that is (are) currently displayed
TW.partialGraph.states[1].type = initialState; TW.partialGraph.states[1].activetypes = initialActivetypes ;
TW.partialGraph.states[1].LouvainFait = false; TW.partialGraph.states[1].LouvainFait = false;
// by default category0 is the initial type // NB specs: categories don't change within a given 'states' array so we don't include them
$(".category1").hide(); // (new graph => new initialActivetypes => new array)
// hide GUI elements of inactive types
for (var catId in initialActivetypes) {
if (!initialActivetypes[catId]) {
$(".for-nodecategory-"+catId).hide();
}
}
// now that we have a sigma instance, let's bind our handlers to it // now that we have a sigma instance, let's bind our click handlers to it
TW.instance.SigmaListeners(TW.partialGraph) TW.instance.SigmaListeners(TW.partialGraph)
// [ / Poblating the Sigma-Graph ] // [ / Poblating the Sigma-Graph ]
// ex called for new selections with args like: // signatures
// (undefined, undefined, [268], undefined) // for new selections: (undefined, undefined, [268], undefined)
// ^^^^ // for new activetypes: ([false, true], undefined, undefined, undefined)
// why type not used (monopart? deprecated?) // for new level: (undefined, false, undefined, undefined)
TW.partialGraph.states[1].setState = (function( type , level , sels , oppos ) { // TODO: method never changes, shouldn't need to be inside each new state!
var bistate=false, typestring=false; TW.partialGraph.states[1].setState = (function( activetypes , level , sels , oppos ) {
var bistate=false, typesKey=false;
console.log("IN THE SET STATE METHOD:", this) console.log("IN THE SET STATE METHOD:", this)
if(!isUndef(type)) { if(!isUndef(activetypes)) {
this.type = type; this.activetypes = activetypes;
bistate= type.map(Number).reduce(function(a, b){return a+b;}) bistate= activetypes.map(Number).reduce(function(a, b){return a+b;})
typestring = type.map(Number).join("|") typesKey = activetypes.map(Number).join("|")
} }
if(!isUndef(level)) this.level = level; if(!isUndef(level)) this.level = level;
if(!isUndef(sels)) this.selections = sels; if(!isUndef(sels)) this.selections = sels;
...@@ -617,7 +625,7 @@ function mainStartGraph(inFormat, inData, twInstance) { ...@@ -617,7 +625,7 @@ function mainStartGraph(inFormat, inData, twInstance) {
this.LouvainFait = false; this.LouvainFait = false;
// console.log("") // console.log("")
// console.log(" % % % % % % % % % % ") // console.log(" % % % % % % % % % % ")
// console.log("setState type: ", type); // console.log("setState activetypes: ", activetypes);
// console.log("bistate: "+bistate) // console.log("bistate: "+bistate)
// console.log("level: "+level); // console.log("level: "+level);
// console.log("selections: "); // console.log("selections: ");
...@@ -635,7 +643,7 @@ function mainStartGraph(inFormat, inData, twInstance) { ...@@ -635,7 +643,7 @@ function mainStartGraph(inFormat, inData, twInstance) {
// console.log(" % % % % % % % % % % ") // console.log(" % % % % % % % % % % ")
// console.log("") // console.log("")
var bistate= this.type.map(Number).reduce(function(a, b){return a+b;}) var bistate= this.activetypes.map(Number).reduce(function(a, b){return a+b;})
LevelButtonDisable(false); LevelButtonDisable(false);
if(level && sels && sels.length==0) if(level && sels && sels.length==0)
LevelButtonDisable(true); LevelButtonDisable(true);
...@@ -644,7 +652,7 @@ function mainStartGraph(inFormat, inData, twInstance) { ...@@ -644,7 +652,7 @@ function mainStartGraph(inFormat, inData, twInstance) {
LevelButtonDisable(true) LevelButtonDisable(true)
// console.log("printing the first state:") // console.log("printing the first state:")
// first_state = TW.partialGraph.states.slice(-1)[0].type; // first_state = TW.partialGraph.states.slice(-1)[0].activetypes;
// for(var i in first_state) { // for(var i in first_state) {
// if(first_state[i]) { // if(first_state[i]) {
// for(var j in Filters[i]) // for(var j in Filters[i])
...@@ -653,36 +661,36 @@ function mainStartGraph(inFormat, inData, twInstance) { ...@@ -653,36 +661,36 @@ function mainStartGraph(inFormat, inData, twInstance) {
// } // }
// console.log("printing the typestring:", typestring) // console.log("printing the typesKey:", typesKey)
// recreate sliders after activetype or level changes
if (TW.filterSliders if (TW.filterSliders
&& (present.level != past.level && (present.level != past.level
|| present.type.map(Number).join("|") != past.type.map(Number).join("|"))) { || present.activetypes.map(Number).join("|") != past.activetypes.map(Number).join("|"))) {
// recreate sliders after type, level changes
// terms // terms
if(typestring=="0|1") { if(typesKey=="0|1") {
$(".category0").hide(); $(".category0").hide();
$(".category1").show(); $(".category1").show();
NodeWeightFilter( "#slidercat1nodesweight" , TW.categories[1], "size"); NodeWeightFilter( "#slidercat1nodesweight" , TW.categories[1], "size");
EdgeWeightFilter("#slidercat1edgesweight", typestring, "weight"); EdgeWeightFilter("#slidercat1edgesweight", typesKey, "weight");
} }
// docs // docs
if(typestring=="1|0") { if(typesKey=="1|0") {
$(".category0").show(); $(".category0").show();
$(".category1").hide(); $(".category1").hide();
NodeWeightFilter( "#slidercat0nodesweight" , TW.categories[0], "size"); NodeWeightFilter( "#slidercat0nodesweight" , TW.categories[0], "size");
EdgeWeightFilter("#slidercat0edgesweight", typestring, "weight"); EdgeWeightFilter("#slidercat0edgesweight", typesKey, "weight");
} }
// terms and docs // terms and docs
if(typestring=="1|1") { if(typesKey=="1|1") {
$(".category0").show(); $(".category0").show();
$(".category1").show(); $(".category1").show();
NodeWeightFilter( "#slidercat0nodesweight" , TW.categories[0], "size"); NodeWeightFilter( "#slidercat0nodesweight" , TW.categories[0], "size");
...@@ -748,9 +756,6 @@ function mainStartGraph(inFormat, inData, twInstance) { ...@@ -748,9 +756,6 @@ function mainStartGraph(inFormat, inData, twInstance) {
// REFA new sigma.js // REFA new sigma.js
TW.partialGraph.camera.goTo({x:0, y:0, ratio:0.9, angle: 0}) TW.partialGraph.camera.goTo({x:0, y:0, ratio:0.9, angle: 0})
$("#category1").hide();
// mostly json data are extracts provided by DB apis => no positions // mostly json data are extracts provided by DB apis => no positions
if (inFormat == "json") TW.fa2enabled = true if (inFormat == "json") TW.fa2enabled = true
......
...@@ -89,27 +89,30 @@ function cancelSelection (fromTagCloud, settings) { ...@@ -89,27 +89,30 @@ function cancelSelection (fromTagCloud, settings) {
// returns the name(s) of active types // returns the name(s) of active types
// this area is quite underspecified so we assume here // this area is quite underspecified so we assume here
// - that all typenames have a mapping to cat[0] (terms) or cat[1] (contexts) // - that all typenames have a mapping to cat[0] (terms) or cat[1] (contexts)
// - that currentState.type is an array of 2 bools for the currently displayed cat(s) // - that currentState.activetypes is an array of 2 bools for the currently displayed cat(s)
// TODO transform result into array in all cases // TODO transform result into array in all cases
function getCurrentType() { function getActivetypesName() {
let currentTypes = [] let currentTypes = []
let currentTypeIdx let currentTypeIdx
let lastState = TW.partialGraph.states.slice(-1)[0] let lastState = TW.partialGraph.states.slice(-1)[0]
for (var possType in TW.catDict) { for (var possType in TW.catDict) {
currentTypeIdx = TW.catDict[possType] currentTypeIdx = TW.catDict[possType]
if (lastState.type[currentTypeIdx]) { if (lastState.activetypes[currentTypeIdx]) {
currentTypes.push(possType) currentTypes.push(possType)
} }
} }
// ex: 'Document' or 'Ngrams' or 'Document-Ngrams'
return currentTypes.join('-') return currentTypes.join('-')
} }
function getCurrentTypeString() { function getActivetypesKey() {
let lastState = TW.partialGraph.states.slice(-1)[0] let lastState = TW.partialGraph.states.slice(-1)[0]
return lastState.type.map(Number).join('|') // ex: '1' or '0|1' or '1|1'
return lastState.activetypes.map(Number).join('|')
} }
...@@ -519,10 +522,10 @@ function graphTagCloudElem(nodes) { ...@@ -519,10 +522,10 @@ function graphTagCloudElem(nodes) {
var catDict = TW.catDict; var catDict = TW.catDict;
var type = TW.Nodes[ndsids[0]].type; var type = TW.Nodes[ndsids[0]].type;
var next_state = []; var nextTypes = [];
for(var c in catDict) for(var c in catDict)
next_state.push( c==type ) nextTypes.push( c==type )
var str_nextstate = next_state.map(Number).join("|") var nextTypesKey = nextTypes.map(Number).join("|")
// £TODO fix low-level selectionlogic duplicate with MultipleSelection2 function 1/2 // £TODO fix low-level selectionlogic duplicate with MultipleSelection2 function 1/2
// Dictionaries of: selection+neighbors // Dictionaries of: selection+neighbors
...@@ -531,7 +534,7 @@ function graphTagCloudElem(nodes) { ...@@ -531,7 +534,7 @@ function graphTagCloudElem(nodes) {
var voisinage = {} var voisinage = {}
for(var i in ndsids) { for(var i in ndsids) {
let nid = ndsids[i]; let nid = ndsids[i];
let neigh = TW.Relations[str_nextstate][nid] let neigh = TW.Relations[nextTypesKey][nid]
if(neigh) { if(neigh) {
for(var j in neigh) { for(var j in neigh) {
t = neigh[j] t = neigh[j]
...@@ -551,7 +554,7 @@ function graphTagCloudElem(nodes) { ...@@ -551,7 +554,7 @@ function graphTagCloudElem(nodes) {
// old strategy recreated a graph with the selected and its neighbors: // old strategy recreated a graph with the selected and its neighbors:
// we know do it only if type is different // we know do it only if type is different
if (str_nextstate != getCurrentTypeString()) { if (nextTypesKey != getActivetypesKey()) {
TW.partialGraph.graph.clear(); TW.partialGraph.graph.clear();
for(var nid in nodes_2_colour) for(var nid in nodes_2_colour)
add1Elem(nid) add1Elem(nid)
...@@ -591,12 +594,12 @@ function graphTagCloudElem(nodes) { ...@@ -591,12 +594,12 @@ function graphTagCloudElem(nodes) {
TW.partialGraph.states[avantlastpos] = {}; TW.partialGraph.states[avantlastpos] = {};
TW.partialGraph.states[avantlastpos].selections = present.selections; TW.partialGraph.states[avantlastpos].selections = present.selections;
TW.partialGraph.states[avantlastpos].level = present.level; TW.partialGraph.states[avantlastpos].level = present.level;
TW.partialGraph.states[avantlastpos].type = present.type; TW.partialGraph.states[avantlastpos].activetypes = present.activetypes;
TW.partialGraph.states[avantlastpos].opposites = present.opposites; TW.partialGraph.states[avantlastpos].opposites = present.opposites;
// recording the new state // recording the new state
TW.partialGraph.states[lastpos].setState({ TW.partialGraph.states[lastpos].setState({
type: next_state, activetypes: nextTypes,
level: false, // forced macro level: false, // forced macro
sels: Object.keys(selections), sels: Object.keys(selections),
oppos: [] oppos: []
......
...@@ -623,8 +623,8 @@ function dictfyGexf( gexf , categories ){ ...@@ -623,8 +623,8 @@ function dictfyGexf( gexf , categories ){
} }
// £TODO second shared function: createRelations() (same for gexf/json) // looping source edges to conforming edge
// then updateRelations
var edgeId = 0; var edgeId = 0;
var edgesNodes = gexf.getElementsByTagName('edges'); var edgesNodes = gexf.getElementsByTagName('edges');
...@@ -960,44 +960,3 @@ function dictfyJSON( data , categories ) { ...@@ -960,44 +960,3 @@ function dictfyJSON( data , categories ) {
return resDict; return resDict;
} }
// to move
function buildInitialState( categories ) {
var firstState = []
for(var i=0; i<categories.length ; i++) {
if(i==0) firstState.push(true)
else firstState.push(false)
}
return firstState;
}
//to move
function makeSystemStates (cats) {
var systemstates = {}
var N=Math.pow(2 , cats.length);
for (i = 0; i < N; i++) {
let bin = (i).toString(2)
let bin_splitted = []
for(var j in bin)
bin_splitted.push(bin[j])
let bin_array = [];
let toadd = cats.length-bin_splitted.length;
for (var k = 0; k < toadd; k++)
bin_array.push("0")
for(var j in bin)
bin_array.push(bin[j])
bin_array = bin_array.map(Number)
let sum = bin_array.reduce(function(a, b){return a+b;})
if( sum != 0 && sum < 3) {
let id = bin_array.join("|")
systemstates[id] = bin_array.map(Boolean)
}
}
return systemstates;
}
...@@ -4,7 +4,7 @@ SigmaUtils = function () { ...@@ -4,7 +4,7 @@ SigmaUtils = function () {
this.nbCats = 0; this.nbCats = 0;
// input = GEXFstring // input = GEXFstring
this.FillGraph = function( initialState , catDict , nodes, edges , graph ) { this.FillGraph = function( initialActivetypes , catDict , nodes, edges , graph ) {
console.log("Filling the graaaaph:") console.log("Filling the graaaaph:")
console.log("FillGraph catDict",catDict) console.log("FillGraph catDict",catDict)
...@@ -14,7 +14,7 @@ SigmaUtils = function () { ...@@ -14,7 +14,7 @@ SigmaUtils = function () {
var n = nodes[i]; var n = nodes[i];
// console.debug('tr >>> fgr node', n) // console.debug('tr >>> fgr node', n)
if(initialState[catDict[n.type]] || TW.debugFlags.initialShowAll) { if(initialActivetypes[catDict[n.type]] || TW.debugFlags.initialShowAll) {
// var node = { // var node = {
// id : n.id, // id : n.id,
// label : n.label, // label : n.label,
...@@ -40,35 +40,17 @@ SigmaUtils = function () { ...@@ -40,35 +40,17 @@ SigmaUtils = function () {
} }
} }
var typeNow = initialState.map(Number).join("|")
for(var i in TW.Relations[typeNow]) { // the typestring of the activetypes is the key to stored Relations (<=> edges)
var activetypesKey = initialActivetypes.map(Number).join("|")
for(var i in TW.Relations[activetypesKey]) {
let s = i; let s = i;
for(var j in TW.Relations[typeNow][i]) { for(var j in TW.Relations[activetypesKey][i]) {
let t = TW.Relations[typeNow][i][j] let t = TW.Relations[activetypesKey][i][j]
let e = TW.Edges[s+";"+t] let e = TW.Edges[s+";"+t]
if(e) { if(e) {
if(e.source != e.target) { if(e.source != e.target) {
// var edge = {
//
// // sigma mandatory properties
// id : e.id,
// source : e.source,
// target : e.target,
//
// // sigma optional properties
// hidden : false,
// color : e.color,
// weight : e.weight,
// // size : e.size,
//
// // twjs additional properties
// type : e.type,
// customAttrs : e.customAttrs
// }
// console.log("edge.color", edge.color)
graph.edges.push( e); graph.edges.push( e);
} }
} }
...@@ -892,7 +874,7 @@ function repaintEdges() { ...@@ -892,7 +874,7 @@ function repaintEdges() {
function colorsRelByBins(daclass) { function colorsRelByBins(daclass) {
var binColors var binColors
var doModifyLabel = false var doModifyLabel = false
var ty = getCurrentType() var ty = getActivetypesName()
// our binning // our binning
var tickThresholds = TW.Clusters[ty][daclass] var tickThresholds = TW.Clusters[ty][daclass]
......
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