# How to create tournament bracket

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

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.

-
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: blog.wolfram.com/2009/03/16/march-madness-in-mathematica – 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];

TreeGraph[
tree,
VertexShape ->
(#1 ->

I think he is not after a drawing, but after the double elimination part en.wikipedia.org/wiki/Double-elimination_tournament – Dr. belisarius Jun 20 '12 at 16:23