我有一个图表,G =(V,E)有几个属性,包括边缘权重属性。我试图根据权重高于x的条件创建子图。
我已尝试使用function compressNumber(number) {
return number.toString(36);
}
function decompressNumber(number) {
return parseInt(number, 36);
}
//Test
console.log("Basic number", 5, compressNumber(5));
console.log('Base 16 example', 15, compressNumber(15));
console.log('A "1" followed by 11 zeroes', Math.pow(10, 11), compressNumber(Math.pow(10, 11)));
console.log('A "1" followed by 11 zeroes, negative', -Math.pow(10, 11), compressNumber(-Math.pow(10, 11)));
console.log('A "1" followed by 11 zeroes, decompressing', Math.pow(10, 11), decompressNumber(compressNumber(Math.pow(10, 11))));
console.log('Biggest 12 digit compressed number', Math.pow(10, 11).toString().replace(/\d/ig, 'z'));
console.log('Biggest 12 digit compressed number decompressed', decompressNumber(Math.pow(10, 11).toString().replace(/\d/ig, 'z')));
的标准R子集选项,但我总是得到一个向量。
我不确定我在这里做错了什么。
答案 0 :(得分:5)
也许你想要这样的东西
parentTreeItem.getChildren().add(treeItem); // makes visible
parentTreeItem.getChildren().remove(treeItem); //makes invisible
答案 1 :(得分:0)
那是因为你用只有子集的边缘替换你的图形g。如果要删除低于阈值权重的边缘,可以使用:
var book = {};
Object.defineProperties(book, {
_year: {
value: 2004
},
edition: {
value: 1
},
year: {
get: function() {
return this._year;
},
set: function(newValue) {
if (newValue > 2004) {
this._year = newValue;
this.edition += newValue - 2004;
}
}
}
});
book.year = 2005;
console.log(book.edition);
console.log(book._year);
console.log(book.year);