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 @@
</ul>
</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)-->
<table>
<tr>
......@@ -215,7 +215,7 @@
</tr>
</table>
</li>
<li class="weight-selectors category1">
<li class="weight-selectors for-nodecategory-1">
<!-- Create a subgraph over nodes from TW.categories[1] (terms)-->
<table>
<tr class="weight-selector">
......
......@@ -29,7 +29,7 @@ function changeGraphAppearanceByFacets( manualflag ) {
// create colormenu
var ty = getCurrentType()
var ty = getActivetypesName()
var color_menu_info = '<li><a href="#" onclick="graphResetColor()">By Default</a></li>';
......@@ -144,11 +144,11 @@ function SomeEffect( ValueclassCode ) {
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
var type_t0 = present.type;
var str_type_t0 = type_t0.map(Number).join("|")
// console.log( "\t"+str_type_t0)
// £TODO factorizable: always the same loop for neighbors this should be handled by a sub of MultipleSelection2
// get the active types code from current state (ie "1", "1|1", etc for TW.Relations lookup)
var activetypesKey = getActivetypesKey()
// console.log( "\t"+activetypesKey)
// we have our precomputed idmaps for nodes_2_colour
// -------------------------------------------------
......@@ -167,8 +167,8 @@ function SomeEffect( ValueclassCode ) {
n.customAttrs['highlight'] = true;
}
if(TW.Relations[str_type_t0] && TW.Relations[str_type_t0][nid] ) {
neigh = TW.Relations[str_type_t0][nid]
if(TW.Relations[activetypesKey] && TW.Relations[activetypesKey][nid] ) {
neigh = TW.Relations[activetypesKey][nid]
if(neigh) {
for(j in neigh) {
tgt_nid = neigh[j]
......@@ -250,7 +250,7 @@ function set_ClustersLegend ( daclass, groupedByTicks ) {
daclass = "louvain"
// usually 'terms' or current display among TW.categories
var curType = getCurrentType()
var curType = getActivetypesName()
// all infos in a bin array
var legendInfo = []
......
......@@ -38,12 +38,11 @@ var TW = {}
// TODO more generic module integrating the variants cf. experiments/histogramModule_STUB_GENERIQUE
TW.DivsFlags["crowdsourcingModule"] = false ;
TW.SystemStates = {}
TW.SystemStates.level = true;
// TW.SystemStates.type = [ true ] //[ true , false ]; //social activated!
TW.SystemStates.type = [ true, false ] //[ true , false ]; //social activated!
TW.SystemStates.selections = [];
TW.SystemStates.opposites = [];
TW.SystemState = {}
TW.SystemState.level = true;
TW.SystemState.type = [ true, false ] // usually overridden by makeSystemStates
TW.SystemState.selections = [];
TW.SystemState.opposites = [];
TW.catSoc = "Document";
TW.catSem = "NGram";
......
......@@ -168,9 +168,9 @@ function SelectionEngine() {
// 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 (typeNow)
// console.log (activetypesKey)
// console.log (" - - - - - - ")
// Dictionaries of: selection+neighbors
......@@ -189,8 +189,8 @@ function SelectionEngine() {
for(var i in ndsids) {
var s = ndsids[i];
if(TW.Relations[typeNow] && TW.Relations[typeNow][s] ) {
var neigh = TW.Relations[typeNow][s]
if(TW.Relations[activetypesKey] && TW.Relations[activetypesKey][s] ) {
var neigh = TW.Relations[activetypesKey][s]
if(neigh) {
for(var j in neigh) {
var t = neigh[j]
......@@ -1021,7 +1021,7 @@ TinaWebJS = function ( sigmacanvas ) {
);
EdgeWeightFilter("#slidercat0edgesweight",
getCurrentTypeString(),
getActivetypesKey(),
"weight"
);
}
......@@ -1057,4 +1057,47 @@ TinaWebJS = function ( sigmacanvas ) {
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() {
var level = present.level;
var sels = present.selections
var type_t0 = present.type;
var str_type_t0 = type_t0.map(Number).join("|")
var t0Activetypes = present.activetypes;
var t0ActivetypesKey = t0Activetypes.map(Number).join("|")
console.debug("CHANGE TYPE, present.selections", present.selections)
......@@ -96,32 +96,32 @@ function changeType() {
// type "grammar"
// used to distinguish types in TW.Relations
// types eg [true] <=> '1'
// [true, true] <=> '1|1'
// [true, false] <=> '1|0'
// activetypes eg [true] <=> key '1'
// [true, true] <=> key '1|1'
// [true, false] <=> key '1|0'
// Complement of the received state ~[X\Y] )
var type_t1 = []
for(var i in type_t0) type_t1[i] = !type_t0[i]
var str_type_t1 = type_t1.map(Number).join("|")
var t1Activetypes = []
for(var i in t0Activetypes) t1Activetypes[i] = !t0Activetypes[i]
var t1ActivetypesKey = t1Activetypes.map(Number).join("|")
var binSumCats = []
for(var i in type_t0)
binSumCats[i] = (type_t0[i]||type_t1[i])
for(var i in t0Activetypes)
binSumCats[i] = (t0Activetypes[i]||t1Activetypes[i])
var str_binSumCats = binSumCats.map(Number).join("|")
var nextState = []
if(level) nextState = type_t1;
if(level) nextState = t1Activetypes;
else nextState = binSumCats;
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("past.type:")
console.log(past.type)
console.log("past.activetypes:")
console.log(past.activetypes)
if(sum_past>1) {
nextState = past.type;
nextState = past.activetypes;
}
}
var str_nextState = nextState.map(Number).join("|")
......@@ -161,32 +161,32 @@ function changeType() {
if(present.level) { //If level=Global, fill all {X}-component
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)
}
}
for(var eid in TW.Edges) {
if(TW.Edges[eid].categ==str_type_t1)
if(TW.Edges[eid].categ==t1ActivetypesKey)
add1Elem(eid)
}
} else /* Local level, change to previous or alter component*/ {
if(sels.length==0) {
console.log(" * * * * * * * * * * * * * * ")
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("the present: ")
console.log(present.type.map(Number)+" , "+present.level)
console.log(present.activetypes.map(Number)+" , "+present.level)
console.log(present)
console.log("str_type_t0: "+str_type_t0)
console.log("str_type_t1: "+str_type_t1)
console.log("t0ActivetypesKey: "+t0ActivetypesKey)
console.log("t1ActivetypesKey: "+t1ActivetypesKey)
console.log("str_nextState: "+str_nextState)
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*/ {
for(var i in prevnodes) {
s = i;
......@@ -201,7 +201,7 @@ function changeType() {
for(var i in nodes_2_colour) {
s = i;
neigh = TW.Relations[str_type_t1][s]
neigh = TW.Relations[t1ActivetypesKey][s]
if(neigh) {
for(var j in neigh) {
t = neigh[j]
......@@ -219,7 +219,7 @@ function changeType() {
for(var eid in edges_2_colour)
add1Elem(eid)
nextState = type_t1;
nextState = t1Activetypes;
}
......@@ -236,19 +236,19 @@ function changeType() {
// console.log(sels)
// 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;})
nextState = (sumFutureCats==2 && !level && sumCats==1 )? nextState : type_t1;
if(str_type_t1=="0|0" ) nextState=past.type;
// nextState = ( past.type && !level && sumCats==1 )? past.type : type_t1;
nextState = (sumFutureCats==2 && !level && sumCats==1 )? nextState : t1Activetypes;
if(t1ActivetypesKey=="0|0" ) nextState=past.activetypes;
// nextState = ( past.activetypes && !level && sumCats==1 )? past.activetypes : t1Activetypes;
str_nextState = nextState.map(Number).join("|")
var sumNextState = nextState.map(Number).reduce(function(a, b){return a+b;})
// [ ChangeType: incremental selection ]
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
var newsels = {}
for(var i in sels) {
......@@ -334,11 +334,11 @@ function changeType() {
TW.partialGraph.states[avantlastpos].LouvainFait = false;
TW.partialGraph.states[avantlastpos].level = present.level;
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[lastpos].setState({
type: nextState,
activetypes: nextState,
level: level,
sels: Object.keys(selections),
oppos: []
......@@ -389,13 +389,13 @@ function changeLevel() {
// types eg [true] <=> '1'
// [true, true] <=> '1|1'
var type_t0 = present.type;
var str_type_t0 = type_t0.map(Number).join("|")
var t0Activetypes = present.activetypes;
var t0ActivetypesKey = t0Activetypes.map(Number).join("|")
// [X|Y]-change (NOT operation over the received state [X\Y] )
var type_t1 = []
for(var i in type_t0) type_t1[i] = !type_t0[i]
var str_type_t1 = type_t1.map(Number).join("|")
var t1Activetypes = []
for(var i in t0Activetypes) t1Activetypes[i] = !t0Activetypes[i]
var t1ActivetypesKey = t1Activetypes.map(Number).join("|")
TW.partialGraph.graph.clear();
......@@ -407,7 +407,7 @@ function changeLevel() {
// POSS: factorize with same strategy in MultipleSelection2 beginning
for(var i in sels) {
s = sels[i];
neigh = TW.Relations[str_type_t0][s]
neigh = TW.Relations[t0ActivetypesKey][s]
if(neigh) {
for(var j in neigh) {
t = neigh[j]
......@@ -452,12 +452,12 @@ function changeLevel() {
// var t0 = performance.now()
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
add1Elem(nid)
}
for(var eid in TW.Edges) {
if(TW.Edges[eid].categ==str_type_t0)
if(TW.Edges[eid].categ==t0ActivetypesKey)
add1Elem(eid)
}
......@@ -484,11 +484,11 @@ function changeLevel() {
TW.partialGraph.states[avantlastpos] = {};
TW.partialGraph.states[avantlastpos].level = present.level;
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[lastpos].setState({
type: present.type,
activetypes: present.activetypes,
level: futurelevel,
sels: Object.keys(selections),
oppos: []
......
......@@ -398,8 +398,10 @@ function mainStartGraph(inFormat, inData, twInstance) {
TW.categories = []
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
var dicts = start.makeDicts(TW.categories); // > parse json or gexf, dictfy
......@@ -468,13 +470,13 @@ function mainStartGraph(inFormat, inData, twInstance) {
// NB new sigma.js: autoResize (no need for AdjustSigmaCanvas + sigmaLimits)
// console.log("categories: "+categories)
// console.log("initial state: "+initialState)
// console.log("initial types: "+initialTypes)
// [ Poblating the Sigma-Graph ]
// preparing the data and settings
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 ---------
......@@ -579,37 +581,43 @@ function mainStartGraph(inFormat, inData, twInstance) {
// POSS make it TW.states
TW.partialGraph.states = []
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
// TW.partialGraph.states[1].categories = TW.categories
// TW.partialGraph.states[1].categoriesDict = TW.catDict;
// from settings_explorer (everything except the type)
TW.partialGraph.states[1] = TW.SystemState
// here 'type' means: the categorie(s) that is (are) currently displayed
TW.partialGraph.states[1].type = initialState;
// activetypes: the node categorie(s) that is (are) currently displayed
TW.partialGraph.states[1].activetypes = initialActivetypes ;
TW.partialGraph.states[1].LouvainFait = false;
// by default category0 is the initial type
$(".category1").hide();
// NB specs: categories don't change within a given 'states' array so we don't include them
// (new graph => new initialActivetypes => new array)
// now that we have a sigma instance, let's bind our handlers to it
// 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 click handlers to it
TW.instance.SigmaListeners(TW.partialGraph)
// [ / Poblating the Sigma-Graph ]
// ex called for new selections with args like:
// (undefined, undefined, [268], undefined)
// ^^^^
// why type not used (monopart? deprecated?)
// signatures
// for new selections: (undefined, undefined, [268], undefined)
// for new activetypes: ([false, true], undefined, undefined, undefined)
// for new level: (undefined, false, undefined, undefined)
TW.partialGraph.states[1].setState = (function( type , level , sels , oppos ) {
var bistate=false, typestring=false;
// TODO: method never changes, shouldn't need to be inside each new state!
TW.partialGraph.states[1].setState = (function( activetypes , level , sels , oppos ) {
var bistate=false, typesKey=false;
console.log("IN THE SET STATE METHOD:", this)
if(!isUndef(type)) {
this.type = type;
bistate= type.map(Number).reduce(function(a, b){return a+b;})
typestring = type.map(Number).join("|")
if(!isUndef(activetypes)) {
this.activetypes = activetypes;
bistate= activetypes.map(Number).reduce(function(a, b){return a+b;})
typesKey = activetypes.map(Number).join("|")
}
if(!isUndef(level)) this.level = level;
if(!isUndef(sels)) this.selections = sels;
......@@ -617,7 +625,7 @@ function mainStartGraph(inFormat, inData, twInstance) {
this.LouvainFait = false;
// console.log("")
// console.log(" % % % % % % % % % % ")
// console.log("setState type: ", type);
// console.log("setState activetypes: ", activetypes);
// console.log("bistate: "+bistate)
// console.log("level: "+level);
// console.log("selections: ");
......@@ -635,7 +643,7 @@ function mainStartGraph(inFormat, inData, twInstance) {
// 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);
if(level && sels && sels.length==0)
LevelButtonDisable(true);
......@@ -644,7 +652,7 @@ function mainStartGraph(inFormat, inData, twInstance) {
LevelButtonDisable(true)
// 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) {
// if(first_state[i]) {
// for(var j in Filters[i])
......@@ -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
&& (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
if(typestring=="0|1") {
if(typesKey=="0|1") {
$(".category0").hide();
$(".category1").show();
NodeWeightFilter( "#slidercat1nodesweight" , TW.categories[1], "size");
EdgeWeightFilter("#slidercat1edgesweight", typestring, "weight");
EdgeWeightFilter("#slidercat1edgesweight", typesKey, "weight");
}
// docs
if(typestring=="1|0") {
if(typesKey=="1|0") {
$(".category0").show();
$(".category1").hide();
NodeWeightFilter( "#slidercat0nodesweight" , TW.categories[0], "size");
EdgeWeightFilter("#slidercat0edgesweight", typestring, "weight");
EdgeWeightFilter("#slidercat0edgesweight", typesKey, "weight");
}
// terms and docs
if(typestring=="1|1") {
if(typesKey=="1|1") {
$(".category0").show();
$(".category1").show();
NodeWeightFilter( "#slidercat0nodesweight" , TW.categories[0], "size");
......@@ -748,9 +756,6 @@ function mainStartGraph(inFormat, inData, twInstance) {
// REFA new sigma.js
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
if (inFormat == "json") TW.fa2enabled = true
......
......@@ -89,27 +89,30 @@ function cancelSelection (fromTagCloud, settings) {
// returns the name(s) of active types
// this area is quite underspecified so we assume here
// - 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
function getCurrentType() {
function getActivetypesName() {
let currentTypes = []
let currentTypeIdx
let lastState = TW.partialGraph.states.slice(-1)[0]
for (var possType in TW.catDict) {
currentTypeIdx = TW.catDict[possType]
if (lastState.type[currentTypeIdx]) {
if (lastState.activetypes[currentTypeIdx]) {
currentTypes.push(possType)
}
}
// ex: 'Document' or 'Ngrams' or 'Document-Ngrams'
return currentTypes.join('-')
}
function getCurrentTypeString() {
function getActivetypesKey() {
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) {
var catDict = TW.catDict;
var type = TW.Nodes[ndsids[0]].type;
var next_state = [];
var nextTypes = [];
for(var c in catDict)
next_state.push( c==type )
var str_nextstate = next_state.map(Number).join("|")
nextTypes.push( c==type )
var nextTypesKey = nextTypes.map(Number).join("|")
// £TODO fix low-level selectionlogic duplicate with MultipleSelection2 function 1/2
// Dictionaries of: selection+neighbors
......@@ -531,7 +534,7 @@ function graphTagCloudElem(nodes) {
var voisinage = {}
for(var i in ndsids) {
let nid = ndsids[i];
let neigh = TW.Relations[str_nextstate][nid]
let neigh = TW.Relations[nextTypesKey][nid]
if(neigh) {
for(var j in neigh) {
t = neigh[j]
......@@ -551,7 +554,7 @@ function graphTagCloudElem(nodes) {
// old strategy recreated a graph with the selected and its neighbors:
// we know do it only if type is different
if (str_nextstate != getCurrentTypeString()) {
if (nextTypesKey != getActivetypesKey()) {
TW.partialGraph.graph.clear();
for(var nid in nodes_2_colour)
add1Elem(nid)
......@@ -591,12 +594,12 @@ function graphTagCloudElem(nodes) {
TW.partialGraph.states[avantlastpos] = {};
TW.partialGraph.states[avantlastpos].selections = present.selections;
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;
// recording the new state
TW.partialGraph.states[lastpos].setState({
type: next_state,
activetypes: nextTypes,
level: false, // forced macro
sels: Object.keys(selections),
oppos: []
......
......@@ -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 edgesNodes = gexf.getElementsByTagName('edges');
......@@ -960,44 +960,3 @@ function dictfyJSON( data , categories ) {
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 () {
this.nbCats = 0;
// 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("FillGraph catDict",catDict)
......@@ -14,7 +14,7 @@ SigmaUtils = function () {
var n = nodes[i];
// console.debug('tr >>> fgr node', n)
if(initialState[catDict[n.type]] || TW.debugFlags.initialShowAll) {
if(initialActivetypes[catDict[n.type]] || TW.debugFlags.initialShowAll) {
// var node = {
// id : n.id,
// label : n.label,
......@@ -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;
for(var j in TW.Relations[typeNow][i]) {
let t = TW.Relations[typeNow][i][j]
for(var j in TW.Relations[activetypesKey][i]) {
let t = TW.Relations[activetypesKey][i][j]
let e = TW.Edges[s+";"+t]
if(e) {
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);
}
}
......@@ -892,7 +874,7 @@ function repaintEdges() {
function colorsRelByBins(daclass) {
var binColors
var doModifyLabel = false
var ty = getCurrentType()
var ty = getActivetypesName()
// our binning
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