Compressible flows typically exhibit multiple shock waves which interact with each other, making the detection of these shock waves crucial for various aspects of flow studies including construction of high-order numerical schemes (e.g., shock-fitting), adaptive grid refinement, and flow visualization. This study aims to effectively identify and localize multiple shock waves and their interaction points in two-dimensional inviscid steady and unsteady flows. A novel shock wave pattern recognition method based on cluster analysis is proposed, including three processes. First, a series of grid-cells located at the transition zones of captured shock waves are extracted using a shock wave detection approach based on local flow variation. Subsequently, these grid-cells are grouped into numerous clusters using the classical K-means clustering algorithm, with categorization based on nearest neighbor features. Finally, a strategy is introduced to merge relevant adjacent clusters and further localize the points where shock waves interact. The Bézier curve fitting technique is then employed to obtain the high-quality shock-lines. Several numerical cases demonstrate that this method achieves high localization accuracy for shock-lines while being minimally affected by grid type and scale variations. Moreover, it enables clear and effective identification of the shock interaction patterns in both steady and unsteady flows, providing an effective visualization means for analyzing the motion and evolution of shock wave configurations.