<div id="sigma-container"></div>
import { layerImage } from "@sigma/node-image";
import Sigma, { DEFAULT_STYLES } from "sigma";
import { extremityArrow, layerFill, pathCurved, sdfRectangle } from "sigma/rendering";
import { getSmallGraph } from "../_data/small-graph";
const container = document.getElementById("sigma-container") as HTMLElement;
const IMAGE_SIZES: Record<string, { width: number; height: number }> = {
a: { width: 600, height: 400 },
b: { width: 400, height: 600 },
c: { width: 600, height: 600 },
d: { width: 800, height: 300 },
e: { width: 300, height: 800 },
f: { width: 500, height: 350 },
const graph = getSmallGraph();
graph.forEachNode((node) => {
const { width, height } = IMAGE_SIZES[node];
graph.mergeNodeAttributes(node, {
image: `https://picsum.photos/${width}/${height}`,
aspectRatio: width / height,
label: `${width} x ${height}`,
new Sigma(graph, container, {
shapes: [sdfRectangle({ cornerRadius: 0.2 })],
image: { type: "string", default: "" },
layers: [layerFill({ color: "#eee" }), layerImage({ textureManagerOptions: { objectFit: "contain" } })],
paths: [pathCurved({ curvature: 0.5 })],
extremities: [extremityArrow({ lengthRatio: 4, widthRatio: 4 })],
autoRescaleContent: "nodes",