Rendering a dynamically created family graph with no overlapping using a depth first search?

前端 未结 5 1829
深忆病人
深忆病人 2021-01-31 07:42

I want to generate this:

With this data structure (ids are random, btw not sequential):

var tree = [
    { \"id\": 1, \"name\": \"Me\", \"dob\":         


        
5条回答
  •  星月不相逢
    2021-01-31 08:22

    This is not trivial question and it involves large corpus of research in graph drawing algorithms.

    The most prominent approach for this problem is through constraints satisfaction. But don't try to implement this on your own (unless you want to learn something new and spend months debugging)

    I cannot recommend highly enough this library: cola.js (GitHub)

    The particular example that may be very close to what you need is grid layout.

提交回复
热议问题