We describe a simple algorithm that computes the recently discovered brane
tilings for a given generic toric singular Calabi-Yau threefold. This therefore
gives AdS/CFT dual quiver gauge theories for D3-branes probing the given
non-compact manifold. The algorithm solves a longstanding problem by computing
superpotentials for these theories directly from the toric diagram of the
singularity. We study the parameter space of a-maximization; this study is made
possible by identifying the R-charges of bifundamental fields as angles in the
brane tiling. We also study Seiberg duality from a new perspective.Comment: 36 pages, 40 figures, JHEP