The present study deals with the limit analysis of masonry walls with rectangular openings by means of the genetic algorithm method. Many experimental results on masonry walls with openings subject to vertical and horizontal loads show importance of shearing resistance of materials including mortar which have a large scatterness of their material properties. Herein, an equivalent shear truss model that can evaluate strength for typical failure patterns due to earthquake damages, such as shear diagonal crack opening, local panel rocking, bed joint sliding, full or partial overturning of an entire wall, is applied to a single masonry wall in-plane collapse. The graph theory contributes topological description of a series of elementary admissible modes and their linear combinations which provide the corresponding load factors at collapse. Thus, it becomes a typical combinatorial optimality problem which can be, herein, approached by the genetic algorithm. A numerical example is compared to the experimental results at the University of Pavia.