Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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
7  
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
6  
Here's one example: blog.wolfram.com/2009/03/16/march-madness-in-mathematica –  Elizabeth Jun 20 '12 at 13:56
1  
@belisarius Team 5 only lost once. Why was it eliminated from the tournament? –  David Carraher Jun 20 '12 at 17:38
1  
@David Two options: The tournament council is a nest of corrupt rats, or I made a mistake –  belisarius Jun 20 '12 at 17:40
    
@David See the new bracket example, pls –  belisarius Jun 20 '12 at 18:35
show 2 more comments

1 Answer 1

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];

TreeGraph[
  tree, 
  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 en.wikipedia.org/wiki/Double-elimination_tournament –  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. –  Jeremy Jun 20 '12 at 19:52
add comment

Your Answer

 
discard

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.