gampleman / elm-visualization

A data visualization library for Elm
http://package.elm-lang.org/packages/gampleman/elm-visualization/latest/
MIT License
514 stars 48 forks source link

Question for non-standard force layout model #156

Closed NicolasWinsten closed 10 months ago

NicolasWinsten commented 10 months ago

Hello

I am trying to make a force layout simulation that displays the graph in a tree like way. By "tree-like", I mean I want the resulting layout to look something like a hierarchical layout where parent nodes will be displayed above child nodes, left child nodes are placed to the left of their sibling nodes, etc. These aren't hard constraints, but I want the layout to trend towards local placements close to this:

          parent
        /        \
leftChild    rightChild

I don't want to use Sugiyama because it is complicated to turn that into an incremental algorithm (nodes in my visualization will be continually added and removed).

My main idea right now is to coarsen the graph by treating some of the local 3-node subgraphs (parent, leftChild, rightChild) as single nodes, and applying a force simulation on that simplified graph. Maybe even treating 2-node subgraphs of (parent, leftChild) as single nodes would be enough.

Is there a more elegant/simple approach?

Thank you