Subgraph isomorphism problem
In theoretical computer science, the subgraph isomorphism problem is a computational task in which two graphs G and H are given as input, and one must determine whether G contains a subgraph that is isomorphic to H. Subgraph isomorphism is a generalization of both the maximum clique problem and the problem of testing whether a graph contains a Hamiltonian cycle, and is therefore NP-complete. However certain other cases of subgraph isomorphism may be solved in polynomial time.
Sometimes the name subgraph matching is also used for the same problem. This name puts emphasis on finding such a subgraph as opposed to the bare decision problem.
Decision problem and computational complexity 
To prove subgraph isomorphism is NP-complete, it must be formulated as a decision problem. The input to the decision problem is a pair of graphs G and H. The answer to the problem is positive if H is isomorphic to a subgraph of G, and negative otherwise.
Let , be graphs. Is there a subgraph such that ? i.e. exists a so that ?
The proof of subgraph isomorphism being NP-complete is simple and based on reduction of the clique problem, an NP-complete decision problem in which the input is a single graph G and a number k, and the question is whether G contains a complete subgraph with k vertices. To translate this to a subgraph isomorphism problem, simply let H be the complete graph Kk; then the answer to the subgraph isomorphism problem for G and H is equal to the answer to the clique problem for G and k. Since the clique problem is NP-complete, this polynomial-time many-one reduction shows that subgraph isomorphism is also NP-complete.
An alternative reduction from the Hamiltonian cycle problem translates a graph G which is to be tested for Hamiltonicity into the pair of graphs G and H, where H is a cycle having the same number of vertices as G. Because the Hamiltonian cycle problem is NP-complete even for planar graphs, this shows that subgraph isomorphism remains NP-complete even in the planar case.
Subgraph isomorphism is a generalization of the graph isomorphism problem, which asks whether G is isomorphic to H: the answer to the graph isomorphism problem is true if and only if G and H both have the same number of vertices and the subgraph isomorphism problem for G and H is true. However the complexity-theoretic status of graph isomorphism remains an open question.
In the context of the Aanderaa–Karp–Rosenberg conjecture on the query complexity of monotone graph properties, Gröger (1992) showed that any subgraph isomorphism problem has query complexity Ω(n3/2); that is, solving the subgraph isomorphism requires an algorithm to check the presence or absence in the input of Ω(n3/2) different edges in the graph.
Ullmann (1976) describes a recursive backtracking procedure for solving the subgraph isomorphism problem. Although its running time is, in general, exponential, it takes polynomial time for any fixed choice of H (with a polynomial that depends on the choice of H). When G is a planar graph and H is fixed, the running time of subgraph isomorphism can be reduced to linear time.
As subgraph isomorphism has been applied in the area of cheminformatics to find similarities between chemical compounds from their structural formula; often in this area the term substructure search is used. Typically a query structure is defined as SMARTS, a SMILES extension.
The closely related problem of counting the number of isomorphic copies of a graph H in a larger graph G has been applied to pattern discovery in databases, the bioinformatics of protein-protein interaction networks, and in exponential random graph methods for mathematically modeling social networks.
Ohlrich et al. (1993) describe an application of subgraph isomorphism in the computer-aided design of electronic circuits. Subgraph matching is also a substep in graph rewriting (the most runtime-intensive), and thus offered by graph rewrite tools.
See also 
- Induced subgraph isomorphism problem
- Maximum common subgraph isomorphism problem
- Maximum common edge subgraph problem
- The original Cook (1971) paper that proves the Cook–Levin theorem already showed subgraph isomorphism to be NP-complete, using a reduction from 3-SAT involving cliques.
- Eppstein (1999)
- Here Ω invokes Big Omega notation.
- Ullmann (1976)
- Kuramochi & Karypis (2001).
- Pržulj, Corneil & Jurisica (2006).
- Snijders et al. (2006).
- Cook, S. A. (1971), "The complexity of theorem-proving procedures", Proc. 3rd ACM Symposium on Theory of Computing, pp. 151–158, doi:10.1145/800157.805047.
- Eppstein, David (1999), "Subgraph isomorphism in planar graphs and related problems", Journal of Graph Algorithms and Applications 3 (3): 1–27, arXiv:cs.DS/9911003.
- Garey, Michael R.; Johnson, David S. (1979), Computers and Intractability: A Guide to the Theory of NP-Completeness, W.H. Freeman, ISBN 0-7167-1045-5. A1.4: GT48, pg.202.
- Gröger, Hans Dietmar (1992), "On the randomized complexity of monotone graph properties", Acta Cybernetica 10 (3): 119–127.
- Kuramochi, Michihiro; Karypis, George (2001), "Frequent subgraph discovery", 1st IEEE International Conference on Data Mining, p. 313, doi:10.1109/ICDM.2001.989534, ISBN 0-7695-1119-8.
- Ohlrich, Miles; Ebeling, Carl; Ginting, Eka; Sather, Lisa (1993), "SubGemini: identifying subcircuits using a fast subgraph isomorphism algorithm", Proceedings of the 30th international Design Automation Conference, pp. 31–37, doi:10.1145/157485.164556, ISBN 0-89791-577-1.
- Pržulj, N.; Corneil, D. G.; Jurisica, I. (2006), "Efficient estimation of graphlet frequency distributions in protein–protein interaction networks", Bioinformatics 22 (8): 974–980, doi:10.1093/bioinformatics/btl030, PMID 16452112.
- Snijders, T. A. B.; Pattison, P. E.; Robins, G.; Handcock, M. S. (2006), "New specifications for exponential random graph models", Sociological Methodology 36 (1): 99–153, doi:10.1111/j.1467-9531.2006.00176.x.
- Ullmann, Julian R. (1976), "An algorithm for subgraph isomorphism", Journal of the ACM 23 (1): 31–42, doi:10.1145/321921.321925.
- Jamil, Hasan (2011), "Computing Subgraph Isomorphic Queries using Structural Unification and Minimum Graph Structures", 26th ACM Symposium on Applied Computing, pp. 1058–1063.