This paper devises an algorithm for finding the minimal set of axial lines that can represent a geometry of building and urban layout in two dimensions. Although axial lines are useful to analyze spatial configuration in the Space Syntax, existing methods for selecting axial lines seldom address the optimality of their solutions. The proposed algorithm uses linear programming to obtain a minimal set of axial lines. To minimize the number of axial lines that represent the entire geometry of building and urban layout, a linear programming problem is established in which a set of axial lines represents the entire geometry. The axial lines must have at least one intersection with every extension line of the wall edges to the sides of the reflex angles. If a solution to this linear programming problem exists, it will be guaranteed to be an optimum. However, some solutions of this general linear programming problem may include isolated lines, which are undesirable for an axial line analysis. To avoid isolated axial lines, this paper states a new formulation by adding a group of constraints to the original formulation. By examining the modified linear programming problem in various two-dimensional building maps and spatial layouts, this paper demonstrates that the proposed algorithm can guarantee a minimum set of axial lines to represent a two-dimensional geometry. This modified linear programming problem prevents isolated axial lines in the process of axial line reduction.