Create edges (drag & click)
Edge creation is built in, with two interaction styles backed by a live "shadow edge" preview: click-click (click a source node, then a target) and drag-and-drop (drag from one node onto another).
Click Edit Graph (top-right), then Add Edge, and connect two nodes — or just drag from one node to another. Every new edge fires the edgeAdd data event, which here pops a toast.
js
// Edge creation lives in the full UI mode. Turn it on and the toolbar's
// Edit Graph → Add Edge starts a click-click (or drag) connect session — the
// shadow-edge preview and both interaction styles come for free.
const options = {
UI: { mode: 'full' }
}js
const data = {
nodes: [
{ id: 'alice', data: { label: 'Alice' } },
{ id: 'bob', data: { label: 'Bob' } },
{ id: 'carol', data: { label: 'Carol' } },
{ id: 'dave', data: { label: 'Dave' } },
{ id: 'erin', data: { label: 'Erin' } }
],
edges: [
{ from: 'alice', to: 'bob' },
{ from: 'alice', to: 'carol' }
]
}