1
|
7028 Views
|
9 Replies
|
4 Total Likes
View groups...
Share
Share this post:
GROUPS:

# Mathematica TreePlot add duplicate elements in subtrees?

Posted 10 years ago
 Is it possible to add p2 to both SysVar2,3 like I drawn ?
9 Replies
Sort By:
Posted 10 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 10 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 10 years ago
 Something Like this will work--it rotates the entire graph: getting the nodes to rotate back to horizontal is beyond my pay grade ;-) Rotate[ TreeForm[A["S1", "S2", S3["wtf", B["S1", "f2"]]], DirectedEdges -> True], \[Pi]/2] 
Posted 10 years ago
 I found an easy way but the only thing I don't know is how to rotate the TreeForm plot to the left Any Ideas :( TreeForm[Root["S1", "S2", S3["wtf", NewLol["S1", "f2"]]], DirectedEdges -> True]
Posted 10 years ago
 I think that it is important to remember that these are Graph rendering functions (in the sense of being graph theoretic) rather than general Graphics functions. Their intent is to create a graphic representation of a graph theoretic data structure which involves edges and vertices. To (mis) quote Gertrude Stein: "Node is a node is a node is a node."But.... you could certainly figure out a way to algorithmically change the repeated right hand side vertices (perhaps on a layer by layer basis if that's your need) in a way that appends a different sequence of invisible spaces to each one as appropriate.
Posted 10 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 10 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 10 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 10 years ago
 Could you give your original code for this so readers could play with it?
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments