function getGraphDataSets() {
const loadTop500_1 = function(Graph) {
Graph
.nameField('title')
.forceEngine('ngraph')
.jsonUrl('.top500.json');
};
loadTop500_1.description = "Top 500 nodes - test";
//
const loadTop500 = function(Graph) {
qwest.get('.top500.json').then((_, data) => {
data.nodes.forEach(node => { node.name = `${node.artist?node.artist+': ':''}${node.title}` });
data.edges.forEach(edge => { edge.value = `${edge.similar}` });
Graph
.cooldownTicks(300)
.forceEngine('ngraph')
.graphData(data);
});
};
loadTop500.description = "Top 500 nodes";
//
const loadD3Dependencies = function(Graph) {
qwest.get('.d3.csv').then((_, csvData) => {
const { data: [, ...data] } = Papa.parse(csvData); // Parse csv
data.pop(); // Remove last empty row
const nodes = [], links = [];
data.forEach(([size, path]) => {
const levels = path.split('/'),
module = levels.length > 1 ? levels[1] : null,
leaf = levels.pop(),
parent = levels.join('/');
nodes.push({
path,
leaf,
module,
size: +size || 1
});
if (parent) {
links.push({ source: parent, target: path});
}
});
Graph
.cooldownTicks(300)
.nodeRelSize(0.5)
.idField('path')
.valField('size')
.nameField('path')
.nodeAutoColorBy('module')
.forceEngine('ngraph')
.graphData({ nodes: nodes, links: links });
});
};
loadD3Dependencies.description = "D3 dependencies data (9a8124ccde3a4e9625bc413b48f14b30)";
const tunnel = function(Graph) {
const perimeter = 12, length = 30;
const getId = (col, row) => `${col},${row}`;
let nodes = [], links = [];
for (let colIdx=0; colIdx0) {
links.push({ source: getId(colIdx, rowIdx-1), target: id });
}
// Link horizontally
links.push({ source: getId((colIdx || perimeter) - 1, rowIdx), target: id });
}
}
Graph
.cooldownTicks(300)
.forceEngine('ngraph')
.graphData({ nodes: nodes, links: links });
};
tunnel.description = "fabric data for a cylindrical tunnel shape";
//
return [loadTop500_1, loadTop500, loadD3Dependencies, tunnel];
}