Public
Edited
Feb 13, 2023
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
fruchterman = {
return new LayoutGPU.FruchtermanLayout({
center: [centerXInFruchtermanLayout, centerYInFruchtermanLayout],
width: widthInFruchtermanLayout,
height: heightInFruchtermanLayout,
maxIteration: maxIterationInFruchtermanLayout,
gravity: gravityInFruchtermanLayout,
speed: speedInFruchtermanLayout
});
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
displayNodesAndEdges(positionsFruchtermanLayoutCalculatedInGPU)
Insert cell
Insert cell
gforce = {
return new LayoutGPU.GForceLayout({
center: [200, 200],
width: 400,
height: 400,
maxIteration: 1000
});
}
Insert cell
calculateGForceLayoutInGPU = () => {
const graph = new graphlib.Graph({
nodes: data2.nodes,
edges: data2.edges
});

return gforce.execute(graph);
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
fruchtermanCPU = {
return new Layout.FruchtermanLayout({
center: [centerXInFruchtermanLayout, centerYInFruchtermanLayout],
width: widthInFruchtermanLayout,
height: heightInFruchtermanLayout,
maxIteration: maxIterationInFruchtermanLayout,
gravity: gravityInFruchtermanLayout,
speed: speedInFruchtermanLayout
});
}
Insert cell
Insert cell
timeElapsedGPU = {
const startTime = performance.now();
await calculateFruchtermanLayoutInGPU();
return performance.now() - startTime;
}
Insert cell
timeElapsedCPU = {
const startTime = performance.now();
await calculateFruchtermanLayoutInCPU();
return performance.now() - startTime;
}
Insert cell
speedUp = timeElapsedCPU / timeElapsedGPU
Insert cell
Insert cell
graphlib = require("@antv/graphlib@2.0.0")
Insert cell
Insert cell
Insert cell
Layout = require("@antv/layout@1.0.0-alpha.16")
Insert cell
LayoutGPU = require("@antv/layout-gpu@1.0.0-alpha.3")
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more