<div id="sigma-container"></div>
import Graph from "graphology";
import Sigma from "sigma";
} from "sigma/rendering";
import { DEFAULT_STYLES } from "sigma/types";
const container = document.getElementById("sigma-container") as HTMLElement;
const graph = new Graph();
const ROW_COLORS = ["#5B8FF9", "#61DDAA", "#F6903D", "#E8684A"];
const PATH_NAMES = ["straight", "curved", "stepCurved", "curvedS"] as const;
{ head: "arrow", tail: "arrow" },
{ dashSize: 5, backgroundColor: "white" },
{ head: "arrow", dashSize: 10, dashColor: "blue" },
for (let rowIdx = 0; rowIdx < PATH_NAMES.length; rowIdx++) {
const pathName = PATH_NAMES[rowIdx];
const rowColor = ROW_COLORS[rowIdx];
for (let colIdx = 0; colIdx < COLUMN_CONFIGS.length; colIdx++) {
const colConfig = COLUMN_CONFIGS[colIdx];
const cellX = colIdx * COL_SPACING;
const cellY = -rowIdx * ROW_SPACING;
const sourceId = `${pathName}-${colIdx}-source`;
graph.addNode(sourceId, {
x: cellX - NODE_SPACING / 2,
const targetId = `${pathName}-${colIdx}-target`;
graph.addNode(targetId, {
x: cellX + NODE_SPACING / 2,
y: cellY + NODE_SPACING / 2,
graph.addEdge(sourceId, targetId, {
color: colConfig.backgroundColor || rowColor,
dashColor: colConfig.dashColor || rowColor,
dashSize: colConfig.dashSize || 0,
curvature: pathName === "curved" ? 0.3 : 0,
new Sigma(graph, container, {
dashColor: { type: "color", default: "#000" },
dashSize: { type: "number", default: 0 },
paths: [pathLine(), pathCurved(), pathStepCurved(), pathCurvedS()],
extremities: [extremityArrow()],
dashColor: { attribute: "dashColor" },
dashSize: { attribute: "dashSize", default: 0, mode: "pixels" },
gapSize: { value: 10, mode: "pixels" },
nodes: [DEFAULT_STYLES.nodes, { size: 12, color: "darkgrey" }],
{ path: { attribute: "path" }, head: { attribute: "head" }, tail: { attribute: "tail" } },
itemSizesReference: "positions",