An Algorithm for Subgraph Isomorphism
J. R. ULLMANN
National Physical Laboratory, Tedd, ngton, M, ddlcsex, England
ABSTRACT. Subgraph isomorphism can be determined by means of a brute-force tree-search enu-
meration procedure. In this paper a new algorithm is introduced that attains efficiency by inferentially
eliminating successor nodes in the tree search. To assess the time actually taken by the new algomthm,
subgraph isomorphism, chque detection, graph isomorphism, and directed graph isomorphism ex-
periments have been carried out with random and with various nonrandom graphs.
A parallel asynchronous logic-in-memory implementation of a vital part of the algorithm is also
described, although this hardware has not actually been bmlt The hardware implementation would
allow very rapid determination of isomorphism.
KEY WORDS AND PHRASES. graph, graph isomorphism, directed graph isomorphism, digraph iso-
morphism, subgraph, subgraph isomorphism, clique, clique detection, isomorphism algorithm, tree
search, search tree, game tree, parallel processing, array processing, special purpose computer, logic-
in-memory arrays, asynchronous sequential circuits, Boolean matrices
CR CATEGORIES" 3 64, 5 32. 6 22
1. Introduction
Corneil and Gotlieb [4] mention that one of the possible applications of subgraph iso-
morphism is for finding whether a given chemical compound is a subcompound of a
further specified compound, given the structural formulas. Subgraph isomorphism may
be useful in scene analysis [1, 10] for detecting a relationally descmbed object that is
embedded in a scene. Problems akin to subgraph isomorphism have also arisen in research
on the recognition of distorted shapes, where any admissible distortion conserves posi-
tional relationships within limits. There is some formal similarity between the problems
of finding whether two graphs are related by a 1:1 correspondence that conserves ad-
jacency and finding whether two patterns are related by a distortion that conserves
spatial relationships within known limits. This idea is explored at an introductory level
in [11, Sec. 7.3]; [11] also indicates the historical origin of the algorithm that is described
in the present paper.
It is well known that isomorphism can be determined by brute-force enumeration. As
a first step toward introducing the original part of our algorithm, Section 2 of this paper
describes a brute-force enumeration procedure that is actually a depth-first tree-search
algorithm. Section 3 introduces the original part of the work, which consists of a proce-
dure that is entered after each node in the tree search. The result of this procedure is
generally a reduction in the number of successor nodes that must be searched, which
yields a reduction in the total computer time required for determining isomorphism.
In Corneil and Gotlieb's algorithm [4], the two graphs that are to be tested for iso-
morphism are separately subjected to a computation which produces representative
Copyright © 1976, Association for Computing Machinery, Inc. General permmslon to republish,
but not for profit, all or part of this material is granted provided that ACM's copyright notice is
given and that reference is made to the publication, to its date of issue, and to the fact that reprinting
privileges were granted by permission of the Association for Computing Machinery.
Author's address. Division of Computer Science, National Physical Laboratory, Teddmgton, Middle-
sex TWll OLW, England.
Journal
of the Assocmtlon for Computing Machinery,
Vol 23, No I, January 1976, pp 31--42