d3.js, collapsible tree - how to connect different parents with same child

前端 未结 1 1203
礼貌的吻别
礼貌的吻别 2021-01-06 14:54

So I am using http://bl.ocks.org/mbostock/4339083 to create a collapsible tree and it works great.

Now the thing is I have some nodes which have the same children, s

相关标签:
1条回答
  • 2021-01-06 15:18

    From your description, I gather you need to visualize directed acyclic graph, or DAG.

    Tree is:

    A
    |\
    B C
     / \
    D   E
    

    DAG is:

    A
    |\
    B C
     \|
      D
    

    And, no, unfortunately, D3 tree and cluster layouts simply don't support that kind of graphs. Their internal algorithms assume that the data structure is strictly a tree.

    However, there are some options. Please see these five related questions for possible approaches:

    d3 tree - parents having same children

    How to layout a non-tree hierarchy with D3

    d3.js tree nodes with same parents

    Layered graphs in d3.js

    JS library for displaying direct acyclic graphs (DAGs)

    0 讨论(0)
提交回复
热议问题