In this paper, we consider the NP-hard problem of finding the metric dimension of graphs. A set of vertices B of a connected graph G = (V, E) resolves G if every vertex of G is uniquely identified by its vector of distances to the vertices in B. The cardinality of the smallest resolving set of G is the metric dimension of G. The metric dimension problem arises in several different fields, such as robot navigation, telecommunication, and geographical routing protocol. The slime mould algorithm (SMA) is an efficient population-based optimizer based on the oscillation mode of slime mould in nature. The SMA has a specific mathematical model and very competitive results, along with fast convergence for many problems, particularly in realworld cases. SMA has good exploration and exploitation abilities for solving optimization problems. However, complex and high-dimensional SMA may fall into local optimal regions. SA is a very preferable technique among the other heuristic approaches as it provides practical randomness in the search to avoid the local extreme points. However, SA involves a tradeoff between computing time and solution sensitivity. The SA is used to enhance the fitness of the best agent if it falls in a suboptimal region, which will lead to the enhancement of all individuals. We solve the problem as integer linear programming and introduce the hybrid algorithm SMA-SA, which combines simulated annealing SA and SMA for determining the metric dimension of graphs. Comparisons were performed on the graphs: k-home chain graph, tadpole graph, alternate triangular snake graph, and mirror graph. Finally, computational results and comparisons with pure SA, SMA, and PSO algorithms confirm the effectiveness of the proposed SMA-SA for solving metric dimension problem.