In this paper, we study a mobile edge computing (MEC) system with the mobile device aided by multiple relay nodes for offloading data to an edge server. Specifically, the modes of decode-and-forward (DF) with time-division-multiple-access (TDMA) and frequency-division-multiple-access (FDMA), and the mode of amplify-and-forward (AF) are investigated, which are denoted as DF-TDMA, DF-FDMA, and AF, respectively. Our target is to minimize the total energy consumption of the mobile device and multiple relay nodes through optimizing the allocation of computation and communication resources. Optimization problems under the three considered modes are formulated and shown to be non-convex. For DF-TDMA mode, we transform the original non-convex problem to be a convex one and further develop a low computation complexity yet optimal solution. In DF-FDMA mode, with some transformation on the original problem, we prove the mathematical equivalence between the transformed problem in DF-FDMA mode and the problem under DF-TDMA mode. In AF mode, the associated optimization problem is decomposed into two levels, in which monotonic optimization is utilized in upper level and successive convex approximation (SCA) is adopted to find the convergent solution in the lower level. Numerical results prove the effectiveness of our proposed methods under various working modes.