Public
Edited
Jun 14, 2024
3 stars
Insert cell
Insert cell
Insert cell
// Load Graphology.
// It is called "Graph" because it is the constructor of the Graph class.
Graph = require('graphology@0.25.1/dist/graphology.umd.min.js')
Insert cell
// Load Graphology Library (layout algorithms, parser, etc.)
GraphologyLibrary = require('graphology-library@0.7.1/dist/graphology-library.min.js')
Insert cell
// Load Sigma.js
sigma = import('https://cdn.skypack.dev/sigma@2.4.0?min')
Insert cell
Insert cell
// Load the network as XML into the variable "arctic"
arctic = FileAttachment("arctic.gexf").xml()
Insert cell
Insert cell
// Parse the XML file.
// We need the parser from Graphology Library, the Graph constructor,
// and of course the file ("arctic").
graph = GraphologyLibrary.gexf.parse(Graph, arctic);
Insert cell
Insert cell
renderer = {
// Create a HTML container
const container = document.createElement('div');
container.style.width = '100%';
container.style.height = '500px';
yield container;

// Create the renderer
const renderer = new sigma.Sigma(graph, container);

// Observable-specific cell management
try {
yield invalidation
}
finally {
renderer.kill();
}
}
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