This paper discusses the optimization of wireless mesh networks (WMN) focusing on cost minimization while also considering the distances between nodes to enhance network performance. Utilizing a Modified Binary Particle Swarm Optimization (MBPSO) approach, the study demonstrated a notable improvement in performance metrics, achieving a 17.83% increase in Packet Delivery Ratio (PDR) and an 8.33% decrease in end-to-end delay. The findings confirm that incorporating distance into cost optimization can lead to better performance outcomes in WMNs.