# Mathematica TreePlot add duplicate elements in subtrees?

Posted 9 years ago
5997 Views
|
9 Replies
|
4 Total Likes
|
 Is it possible to add p2 to both SysVar2,3 like I drawn ?
9 Replies
Sort By:
Posted 9 years ago
 It can be done quite easily using Graph:  Graph[{Labeled[1, "1"], Labeled[2, "2"], Labeled[3, "3"], Labeled[4, "4"], Labeled[5, "5"], Labeled[6, "5"]}, {1 <-> 2, 2 <-> 3, 2 <-> 4, 3 <-> 5, 4 <-> 6}, GraphLayout -> "LayeredDigraphEmbedding"] In this notation you separate the definitions for connections and for labels.
Posted 9 years ago
 By the way, the code in this thread shows how to rotate the text in the node labels:http://community.wolfram.com/groups/-/m/t/395664
Posted 9 years ago
Posted 9 years ago
Posted 9 years ago
Posted 9 years ago
 I used a combination of spaces and replacements , but it gets out of hand quickly. There must be added a feature for this IN THE NEXT MATHEMATICA VERSION FFS !!! listNodesSubsystemView = Join[{ "XXX" -> "SubSystems"}, Reverse[{"SubSystems" -> "SysVar1", "SubSystems" -> "SysVar2", "SubSystems" -> "SysVar3"}], Reverse[ {"SysVar1" -> "p1S1", "SysVar1" -> "p2S1", "SysVar1" -> "p3S1", "SysVar2" -> "p1S2", "SysVar2" -> "p2S2", "SysVar2" -> "p3S2", "SysVar3" -> "p3S3"}], Reverse[{"p1S1" -> "Sp11", "p1S1" -> "Sp12", "p2S1" -> "Sp21", "p2S1" -> "Sp22",(*in system variant S1*) "p1S2" -> " Sp11", "p2S2" -> " Sp21", "p3S2" -> " Sp31", "p3S2" -> " Sp32",(*in system variant S2*) "p3S3" -> " Sp31"}]];(*in system variant S3*) TreeSubSystem = TreePlot[listNodesSubsystemView, Left, First[ First[listNodesSubsystemView]], VertexLabeling -> True, DirectedEdges -> True] /. "p2S1" | "p2S2" | "p2S3" -> "p2" /. "p3S1" | "p3S2" | "p3S3" -> "p3" /. "p1S1" | "p1S2" | "p1S3" -> "p1"; 
Posted 9 years ago
 Well one way, which is a REAL HACK is to replace one of your instances of "p2" by "p2 " I.e. add a space (which can be an invisible space (http://reference.wolfram.com/language/ref/character/InvisibleSpace.html)But since TreeGraph is crating a connectivity graph, if these two vertices are not different in some way then it will, correctly, display the vertex once with multiple edges linking to it.
Posted 9 years ago
 The code for the pic above is :  listNodesSubsystemView = Join[{"xxx" -> "SubSystems"}, Reverse[{"SubSystems" -> "SysVar1", "SubSystems" -> "SysVar2", "SubSystems" -> "SysVar3"}], Reverse[{"SysVar1" -> "p1", "SysVar2" -> "p2", "SysVar3" -> "p3", "SysVar3" -> "p2"}], Reverse[{{"p1" -> "Sp11", "value set"}, {"p1" -> "Sp12", "value set"}, {"p3" -> "Sp31", "value set"}, {"p3" -> "Sp32", "value set"}}], {{"p2" -> "Sp21", "value set"}}]; TreeSubSystem = TreePlot[listNodesSubsystemView, Left, First[First[listNodesSubsystemView]], VertexLabeling -> True, DirectedEdges -> True] 
Posted 9 years ago
 Could you give your original code for this so readers could play with it?