admin管理员组

文章数量:1327115

So I am using to create a collapsible tree and it works great.

Now the thing is I have some nodes which have the same children, so I want to know if there is any way to visualize the graph in such a way that both the parents expand to the same child?

So basically when you expand the node of a parent it should automatically expand the node of the other parent leading to the same mon child, is this possible with any graph?

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

Now the thing is I have some nodes which have the same children, so I want to know if there is any way to visualize the graph in such a way that both the parents expand to the same child?

So basically when you expand the node of a parent it should automatically expand the node of the other parent leading to the same mon child, is this possible with any graph?

Share Improve this question edited Jan 15, 2015 at 15:34 VividD 10.5k8 gold badges66 silver badges112 bronze badges asked Dec 31, 2013 at 7:19 X-joX-jo 6011 gold badge6 silver badges13 bronze badges 5
  • Maybe a collapsible force layout is more suitable for you? – Lars Kotthoff Commented Dec 31, 2013 at 9:50
  • its still the same, two parents don't expand to one node. ViviD says in the response that this can't be done by d3 alone. – X-jo Commented Dec 31, 2013 at 14:12
  • 1 It can be done in D3, just not with the existing layouts. It would be easier to implement with a force layout than with a tree layout though. – Lars Kotthoff Commented Dec 31, 2013 at 14:38
  • stackoverflow./questions/20525458/… i will try this, thanks – X-jo Commented Jan 1, 2014 at 10:18
  • X-jo can you post your findings? – mehmet Commented Dec 26, 2015 at 18:22
Add a ment  | 

1 Answer 1

Reset to default 6

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)

本文标签: javascriptD3jscollapsible treehow to connect different parents with same childStack Overflow