Device-to-device (D2D)-assisted decentralized learning has been proposed for mobile devices to collaboratively train artificial intelligence networks without the centralized parameter server. However, a densely connected network will cause large learning latency and energy consumption due to the limited computation and communication resources. In addition, link selection and aggregation weight have a significant impact on the learning performance. To cope with these challenges, we propose a joint computing power adjustment, wireless resource allocation, link selection, and aggregation weight adaptation mechanism to improve both communication and energy efficiencies. Specifically, the learning performances including the convergence rate, per-iteration learning latency, and per-iteration energy consumption are first analyzed. Then, an optimization problem is formulated to minimize the total learning cost, which is defined as the weighted sum of total learning latency and energy consumption. Given a network topology, the computing power and wireless resource allocation are optimized by the alternating optimization algorithm. Moreover, the optimal aggregation weight is obtained by semidefinite programming. With respect to link selection, we propose a tabu search based meta-heuristic algorithm to approximately achieve feasible solutions with a low computational complexity. Finally, extensive experiments demonstrate that the proposed link selection algorithm can significantly reduce the learning cost under the given learning accuracy requirement.