Basic Rendering
This page starts with the smallest complete Helios Web program. It creates a
WASM-backed graph, adds a few nodes and edges, mounts Helios into the render
area provided by the example, and lets Helios choose the renderer and default
GPU-force layout. In browsers with WebGPU support, Helios can use WebGPU;
otherwise it falls back to WebGL2.
Nothing in this first example configures mappers, labels, legends, cleanup,
renderer preferences, or layout parameters. Those features matter, but they are
not needed to understand the basic contract: a helios-network graph goes into
the Helios constructor, and the Helios instance owns the visual view.
The default behaviors are already attached. That means later examples can call
helios.behavior.selection, helios.behavior.mappers,
helios.behavior.filters, and the rest of the behavior namespace without
enabling those behaviors one by one.
{"importMap": {"helios-web": "../vendor/helios/helios-web.es.js", "helios-network": "../vendor/helios/helios-network.js"}, "examples": [{"id": "examples--helios-web--basic.md--example-1", "title": "Render A Small Graph", "render": true, "console": true, "autorun": true, "layout": "split", "width": null, "height": "420px", "headerName": null, "headerCode": "", "bodyName": "helios_web_basic_rendering", "bodyCode": "import HeliosNetwork from \"helios-network\";\nimport { Helios } from \"helios-web\";\n\nconst network = await HeliosNetwork.create({ directed: false });\n\nconst nodes = network.addNodes(8);\nnetwork.addEdges([\n [nodes[0], nodes[1]], [nodes[1], nodes[2]], [nodes[2], nodes[3]],\n [nodes[3], nodes[4]], [nodes[4], nodes[5]], [nodes[5], nodes[6]],\n [nodes[6], nodes[7]], [nodes[7], nodes[0]], [nodes[0], nodes[4]],\n]);\n\nconst helios = new Helios(network, {\n container,\n mode: '2d',\n});\n\nawait helios.ready;\nawait new Promise((resolve) => setTimeout(resolve, 900));\nhelios.frameNetwork({ animate: false });", "headerRefs": [], "bodyRefs": []}]}