<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();
{ name: "straight", color: "#5B8FF9" },
{ name: "curved", color: "#61DDAA", curvature: 0.3 },
{ name: "curvedS", color: "#F6903D" },
// Two groups side by side: head-only (left) and head+tail (right)
const GROUP_SPACING = PATHS.length * COL_SPACING + 40;
const GROUPS: { head?: string; tail?: string }[][] = [
[{ head: "arrow" }, { head: "circle" }, { head: "diamond" }, { head: "bar" }, { head: "square" }],
{ head: "arrow", tail: "arrow" },
{ head: "arrow", tail: "circle" },
{ head: "diamond", tail: "bar" },
{ head: "circle", tail: "square" },
{ head: "square", tail: "diamond" },
for (let groupIdx = 0; groupIdx < GROUPS.length; groupIdx++) {
const group = GROUPS[groupIdx];
for (let rowIdx = 0; rowIdx < group.length; rowIdx++) {
const { head, tail } = group[rowIdx];
for (let colIdx = 0; colIdx < PATHS.length; colIdx++) {
const { name: path, color, curvature } = PATHS[colIdx];
const cellX = groupIdx * GROUP_SPACING + colIdx * COL_SPACING;
const cellY = -rowIdx * ROW_SPACING;
const sourceId = `${groupIdx}-${rowIdx}-${colIdx}-s`;
const targetId = `${groupIdx}-${rowIdx}-${colIdx}-t`;
graph.addNode(sourceId, {
x: cellX - NODE_SPACING / 2,
graph.addNode(targetId, {
x: cellX + NODE_SPACING / 2,
y: cellY + NODE_SPACING * 0.6,
graph.addEdge(sourceId, targetId, {
curvature: curvature ?? 0,
new Sigma(graph, container, {
paths: [pathLine(), pathCurved(), pathCurvedS()],
extremities: [extremityArrow(), extremityCircle(), extremityDiamond(), extremityBar(), extremitySquare()],
nodes: [DEFAULT_STYLES.nodes, { size: 12, color: "darkgrey" }],
{ path: { attribute: "path" }, head: { attribute: "head" }, tail: { attribute: "tail" } },
itemSizesReference: "positions",