Commit 66183b2b authored by Romain Loth's avatar Romain Loth

better strategy for situations where Card({observed nodetypes}) > 2

parent 1ad12dcd
...@@ -651,10 +651,16 @@ function dictfyGexf( gexf , categories ){ ...@@ -651,10 +651,16 @@ function dictfyGexf( gexf , categories ){
// NB nodesByType lists arrays of ids per nodetype // NB nodesByType lists arrays of ids per nodetype
// (equivalent to TW.partialGraph.graph.getNodesByType but on full nodeset) // (equivalent to TW.partialGraph.graph.getNodesByType but on full nodeset)
for(var i in categories) { for(var i in categories) {
catDict[categories[i]] = i
nodesByType[i] = [] nodesByType[i] = []
let subCats = categories[i].split(/\//g)
for (var j in subCats) {
catDict[subCats[j]] = i
}
} }
var elsNodes = gexf.getElementsByTagName('nodes') // The list of xml nodes 'nodes' (plural) var elsNodes = gexf.getElementsByTagName('nodes') // The list of xml nodes 'nodes' (plural)
TW.labels = []; TW.labels = [];
...@@ -1057,8 +1063,13 @@ function dictfyJSON( data , categories ) { ...@@ -1057,8 +1063,13 @@ function dictfyJSON( data , categories ) {
// NB nodesByType lists arrays of ids per nodetype // NB nodesByType lists arrays of ids per nodetype
// (equivalent to TW.partialGraph.graph.getNodesByType but on full nodeset) // (equivalent to TW.partialGraph.graph.getNodesByType but on full nodeset)
for(var i in categories) { for(var i in categories) {
catDict[categories[i]] = i
nodesByType[i] = [] nodesByType[i] = []
let subCats = categories[i].split(/\//g)
for (var j in subCats) {
catDict[subCats[j]] = i
}
} }
// normalization, same as parseGexf // normalization, same as parseGexf
...@@ -1111,6 +1122,7 @@ function dictfyJSON( data , categories ) { ...@@ -1111,6 +1122,7 @@ function dictfyJSON( data , categories ) {
// record // record
nodes[node.id] = node; nodes[node.id] = node;
if (!nodesByType[catDict[node.type]]) { if (!nodesByType[catDict[node.type]]) {
console.warn("unrecognized type:", node.type) console.warn("unrecognized type:", node.type)
} }
......
...@@ -97,11 +97,10 @@ var SigmaUtils = function () { ...@@ -97,11 +97,10 @@ var SigmaUtils = function () {
settings('labelSizeRatio') * size; settings('labelSizeRatio') * size;
// apply type-specific size slider ratios // apply type-specific size slider ratios
var typeId = TW.categories.indexOf(node.type) || 0 var typeId = TW.catDict[node.type] || 0
size *= TW.gui.sizeRatios[typeId] size *= TW.gui.sizeRatios[typeId]
fontSize *= TW.gui.sizeRatios[typeId] fontSize *= TW.gui.sizeRatios[typeId]
if (!activeFlag && fontSize < settings('labelThreshold') * settings('labelSizeRatio')) if (!activeFlag && fontSize < settings('labelThreshold') * settings('labelSizeRatio'))
return; return;
...@@ -292,7 +291,7 @@ var SigmaUtils = function () { ...@@ -292,7 +291,7 @@ var SigmaUtils = function () {
// NB cost of this condition seems small: // NB cost of this condition seems small:
// - without: [11 - 30] ms for 23 nodes // - without: [11 - 30] ms for 23 nodes
// - with : [11 - 33] ms for 23 nodes // - with : [11 - 33] ms for 23 nodes
var typeId = TW.categories.indexOf(node.type) || 0 var typeId = TW.catDict[node.type] || 0
// apply type-specific size slider ratios // apply type-specific size slider ratios
nodeSize *= TW.gui.sizeRatios[typeId] nodeSize *= TW.gui.sizeRatios[typeId]
...@@ -421,7 +420,7 @@ var SigmaUtils = function () { ...@@ -421,7 +420,7 @@ var SigmaUtils = function () {
// largerall: our customized size boosts // largerall: our customized size boosts
// apply type-specific size slider ratios // apply type-specific size slider ratios
var typeId = TW.categories.indexOf(node.type) || 0 var typeId = TW.catDict[node.type] || 0
size *= TW.gui.sizeRatios[typeId] size *= TW.gui.sizeRatios[typeId]
fontSize *= TW.gui.sizeRatios[typeId] fontSize *= TW.gui.sizeRatios[typeId]
......
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