  We evaluate the Nekrasov partition function of 5d gauge theories engineered
by webs of 5-branes, using the refined topological vertex on the dual
Calabi-Yau threefolds. The theories include certain non-Lagrangian theories
such as the T_N theory. The refined topological vertex computation generically
contains contributions from decoupled M2-branes which are not charged under the
5d gauge symmetry engineered. We argue that, after eliminating them, the
refined topological string partition function agrees with the 5d Nekrasov
partition function. We explicitly check this for the T_3 theory as well as
Sp(1) gauge theories with N_f = 2, 3, 4 flavors. In particular, our method
leads to a new expression of the Sp(1) Nekrasov partition functions without any
contour integrals. We also develop prescriptions to calculate the partition
functions of theories obtained by Higgsing the T_N theory. We compute the
partition function of the E_7 theory via this prescription, and find the E_7
global symmetry enhancement. We finally discuss a potential application of the
refined topological vertex to non-toric web diagrams.
