Wrt using a canvas and doing layout yourself vs using Compose’s layouts, depends how fancy you want your graph layout to be I guess. I’m not sure if you can adequately describe a complicated graph layout using compose’s layout system, which uses a box model, but for a simple tree I could see that working.
If you
do decide to use compose’s layout system, i think you could wire up a custom layout that would draw the connectors automatically. The tricky bit is reporting the final positions of each of your graph nodes in an arbitrarily deep hierarchy of LayoutNodes. You could do this with
onGloballyPositioned
, but you’d always have a frame of lag between drawing your graph nodes and drawing the connectors. You might be able to do something hacky where you cast
Placeables
to `LayoutNode`s and figure out their position relative to your custom layout, but i’m not sure if that’s possible, and even if it is, it would be hacky and brittle.