I want to model a random tournament. Say that there are four candidates to simplify.

I want to construct a tree with vertices depending on the result. For instance, if $a$ encounters $b$ and $a$ wins, the corresponding vertex must change.

The only part of this programme I have been able to write is

g = {a -> 5, b -> 5, c -> 6, d -> 6 , 5 -> 7, 6 -> 7 }
TreePlot[g, Right, VertexLabeling -> True]

How to change the vertices? One colleague suggested to construct all possible trees and to display only the one corresponding to the result. For instance if the random draw result is $a$ wins against $b$ and $c$ wins against $d$ and $a$ wins against to display the corresponding tree. But in that case I don't know how to do this since TreePlot uses the name of the vertices and in that case one cannot use two times the same name.


1 Answer 1


You could change the vertices after the tree plot is created, with a replacement rule. e.g.

g = {a -> ab, b -> ab, c -> cd, d -> cd, ab -> abcd, cd -> abcd};

TreePlot[g, Right, VertexLabeling -> True] /. {ab -> a, cd -> d, abcd -> d}

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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