Graph matching is a comparison process of two objects represented as graphs through finding a correspondence between vertices and edges. This process allows defining a similarity degree (or dissimilarity) between the graphs. Generally, graph matching is used for extracting, finding and retrieving any information or sub-information that can be represented by graphs. In this paper, a new consistency rule is proposed to tackle with various problems of graph matching. After, using the proposed rule as a necessary and sufficient condition for the graph isomorphism, we generalize it for subgraph isomorphism, homomorphism and for an example of inexact graph matching. To determine whether there is a matching or not, a backtracking algorithm called CRGI2 is presented who checks the consistency rule by exploring the overall search space. The tree-search is consolidated with a tree pruning technique that eliminates the unfruitful branches as early as possible. Experimental results show that our algorithm is efficient and applicable for a real case application in the information retrieval field. On the efficiency side, due to the ability of the proposed rule to eliminate as early as possible the incorrect solutions, our algorithm outperforms the existing algorithms in the literature. For the application side, the algorithm has been successfully tested for querying a real dataset that contains a large set of e-mail messages.