Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'd like to create a tournament bracket using Mathematica. I've looked around online, but haven't found any examples yet. Can someone show me how to do this? Specifically, I'd like to have a (somewhat) arbitrary number of participants in a double-elimination bracket.

Edit by belisarius

An example of a double elimination bracket follows

enter image description here

Each team has to be beaten twice to be eliminated. There are a winners and a losers circuit, and when a team loses a match in the winner's side, it enters the losers circuit in an appropriate place, so not to be confronted with past competitors.

share|improve this question
What have you tried? "Can someone show me how to do this?" isn't a very inviting question. We aren't here to do your job for you. I would suggest trying to use a combination of primitive graphics (Line, Text, etc.) to put something together. The LevelScheme package might be helpful as well. – tkott Jun 20 '12 at 13:20
Here's one example: – Elizabeth Jun 20 '12 at 13:56
@belisarius Team 5 only lost once. Why was it eliminated from the tournament? – DavidC Jun 20 '12 at 17:38
@David Two options: The tournament council is a nest of corrupt rats, or I made a mistake – Dr. belisarius Jun 20 '12 at 17:40
@David See the new bracket example, pls – Dr. belisarius Jun 20 '12 at 18:35

Here a basic idea for starters. I use a binary tree which is visualized with TreeGraph. A custom EdgeShapeFunction takes care of the right-angled edges. I leave further customizing of the labels and the rest of the tree as an exercise to the reader.

tree = Flatten@
   Table[{i \[UndirectedEdge] 2 i, i \[UndirectedEdge] 2 i + 1}, {i, 1, 2^4 - 1}];

start = RandomSample[CountryData["EuropeanUnion"], 16];

tournament= Reverse@Flatten@NestList[
     Flatten[(Function[{win}, RandomSample[win, 1]] /@ Partition[#, 2])] &, start, 5];

  VertexShape -> 
     (#1 -> 
       Graphics[Style[Text[#2], 14], PlotRangePadding -> 0.2, 
                ImageSize -> 1.5 {40, 15}
       ] & @@@ ({Range[31], tournament}\[Transpose])
  VertexSize -> 1, EdgeStyle -> Blue, 
  EdgeShapeFunction -> ({Line[{#1[[1]], {#1[[2, 1]], #1[[1, 2]]}, #1[[2]]}]} &)

Mathematica graphics

share|improve this answer
I think he is not after a drawing, but after the double elimination part – Dr. belisarius Jun 20 '12 at 16:23
This looks great! I am interested in drawing, but also double elimination. I don't have something to start with; I was hoping someone had already created something I could start with. I didn't know about the TreeGraph so this looks like something I could use, but definitely needs double elimination. – jlconlin Jun 20 '12 at 19:52

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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