Rooted tree
A deterministic spanning tree with labels and curved directional links.
Static preview; loading the interactive plot
<script>
import { Data, GraphData, Tree, Plot, Nodes, Edges, Points, Text, InputContext, Select, categories, input } from '$lib';
import { Arrows } from '$lib/charts/index.js';
import {untrack} from 'svelte';
let {plot=$bindable(),onready=undefined}=$props();
$effect(()=>{const p=plot;untrack(()=>onready?.(p));});
const data={source:['Root','Root','Left','Left','Right','Right','Isolated'],target:['Left','Right','Leaf A','Leaf B','Leaf C','Leaf D','Other']};
</script>
<InputContext><Data value={data}>
<Select name="root" options={categories("source")} value="Root" label="Root"/>
<Select name="orientation" options={["down","up","left","right"]} label="Orientation"/>
<GraphData><Tree root={input("root")} orientation={input("orientation")}>
<Plot bind:this={plot} responsive height={440} x={{domain:[-1,5]}} y={{domain:[-3,1]}}>
<Edges><Arrows start="start" end="end" curve="link-vertical" width={1} color="#7b9865"/></Edges>
<Nodes><Points position="position" size={4} fill="#547ba2"/><Text x="x" y="y" text="id" dy={-14}/></Nodes>
</Plot>
</Tree></GraphData></Data></InputContext>