2

I have a list of rules that I would like to show as a layered graph. However, some vertex names appear more than once. How would one best deal with this situation?

Example:

rules = {"Question 1" -> "Question 2", "Question 1" -> "Question 3", 
"Question 2" -> "Yes", "Question 2" -> "No", 
"Question 3" -> "Yes", "Question 3" -> "No"};
LayeredGraphPlot[rules, VertexLabeling -> True]

Produces:

enter image description here

It makes more sense for question 2 and question 3 to have one "Yes" and one "No" box each, is there an easy way to accomplish this? (Besides the obvious one: More descriptive, unique, vertex names.)

V.E.
  • 1,700
  • 17
  • 16

1 Answers1

1

A cheap way (look ma, no thinking):

TreeForm[Question1[Question2[Yes, No], Question3[Yes, No]]]

Mathematica graphics

But I doubt Mathematica is the best tool for these things

Dr. belisarius
  • 115,881
  • 13
  • 203
  • 453
  • Yes, I suppose. It's not really an expected option for a graph, I just threw the question out there in case I'd missed something. I ended up taking the easy way out and added level specification to the vertices which made it look okay-ish: http://mathematica.stackexchange.com/questions/75801/creating-identification-classification-trees/95292#95292 But one should probably think of how to present it before writing any other code... – V.E. Sep 23 '15 at 13:24