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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more