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?


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]


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.)


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

  • $\begingroup$ 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: mathematica.stackexchange.com/questions/75801/… But one should probably think of how to present it before writing any other code... $\endgroup$
    – V.E.
    Sep 23 '15 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.