This paper tackles the distributed computing problem in a joint cellular and device-to-device (D2D) network, where edge users can exchange information both through an access point (e.g., base station) and D2D communication links. The D2D network consists of multiple disjoint clusters, where multiple users can transmit signals simultaneously to their neighbouring users within the same cluster, due to disjoint connections between clusters. A nested coded distributed computation (CDC) scheme is proposed to reduce the communication load both in the uplink and downlink communication, by leveraging coding techniques and parallel transmission opportunities in the D2D network. It is shown that this scheme is optimal in the sense that it achieves the minimum communication load both in the uplink and downlink. The nested CDC scheme can also reduce the coding complexity, compared with the conventional wireless CDC scheme proposed by Li et al., whose computational complexity grows exponentially with the computation load.