## 1 Introduction
In the current strategy, the case where the UAV simultaneously performs data relaying and edge computing may be considered, and this approach enhances the function of the UAV in the MEC fusion network. Such a flexible network layout can maximize the advantages of the fusion network, which can not only undertake considerable data processing but also increase the network reliability. [PERSON], [PERSON] et al. [21] aimed at minimum energy consumption and studied the edge offloading of UAV-assisted relaying and computation by applying the iterative algorithm through the Lagrangian duality method and successive convex approximation (SCA) technique. [PERSON], [PERSON] et al. [22] studied the architecture of a UAV-assisted MEC. During multiple constraints where the UAV simultaneously relayed data and computing tasks, the study used alternating iterations to identify the optimal computational resource scheduling, bandwidth allocation, and UAV trajectory with the minimum weighted energy consumption as the goal. In the above study, the UAV performs relay and computing tasks in the same time slot, but the two functions are not really distinguished among different sizes of tasks. Moreover, the burden of both functions on the already energy-limited UAV load and consumption is remarkably large, and an extremely complex task undertaken by the UAV will greatly reduce the UAV working time. Furthermore, the delay limitation problem is not considered. Unlike [21] and [22], the present study perceives that the UAV assumes only one function of relay or MEC when the task is offloaded, and this method establishes a multilevel edge network resource optimization model (MENROM) to optimize the function selection of the UAV in the MEC network. The above resource allocation algorithm does not consider the current actual energy state of the UAV. Green energy (e.g., solar energy) will provide the UAV with a longer and stronger battery life in the network. The cost of the UAV processing task will be affected by its own energy surplus factors and will then affect the overall network utility. In heterogeneous networks, low-cost networks (e.g., Wi-Fi networks) can reduce transmission costs and cause the task offloading process to take full advantage of resources [23]. In view of the energy and network situation and considering the UAV relay function, this study proposes a MENROM based on the MDP algorithm. In summary, the main contributions of this work are presented as follows:  
* A multilevel offloading network structure model with terminal devices, UAV, and remote G-MEC server is constructed for scenarios with long-range and low-cost coverage, such as emergency communication, in which the UAV with a green energy charging function assumes two functions: the relay node and MEC server. * The UAV energy case is divided into four energy levels to determine its energy status. Considering the current energy level state of the UAV, this study proposes an optimal resource allocation and task offloading strategy according to the energy level and comprehensive performance evaluation. The model selects optimal resource allocation and makes task offloading decisions on the basis of UAV energy levels and system resources. The MDP is applied to solve the model's offloadingproblem. In addition the optimal resource optimization and offloading decision are obtained using the iterative method. * Considering the network performance evaluation, BER in the network and interrupt probability, the reliability indexes is set. The reliability indexes indicates the probability of successfully offloading the computing task to the computing node to complete the calculation and return of the result. The normalized delay, energy consumption, and other parameters increase the reliability of the system. According to the above setting, this study conducts a simulation analysis of the network and realizes multilevel edge network resource optimization and the intelligent offloading decision.