Flexible Graph Matching and Graph Edit Distance Using Answer Set Programming

  • Sheung Chi Chan
  • James CheneyEmail author
Conference paper
Part of the Lecture Notes in Computer Science book series (LNCS, volume 12007)


The graph isomorphism, subgraph isomorphism, and graph edit distance problems are combinatorial problems with many applications. Heuristic exact and approximate algorithms for each of these problems have been developed for different kinds of graphs: directed, undirected, labeled, etc. However, additional work is often needed to adapt such algorithms to different classes of graphs, for example to accommodate both labels and property annotations on nodes and edges. In this paper, we propose an approach based on answer set programming. We show how each of these problems can be defined for a general class of property graphs with directed edges, and labels and key-value properties annotating both nodes and edges. We evaluate this approach on a variety of synthetic and realistic graphs, demonstrating that it is feasible as a rapid prototyping approach.



Effort sponsored by the Air Force Office of Scientific Research, Air Force Material Command, USAF, under grant number FA8655-13-1-3006. The U.S. Government and University of Edinburgh are authorised to reproduce and distribute reprints for their purposes notwithstanding any copyright notation thereon. Cheney was also supported by ERC Consolidator Grant Skye (grant number 682315). This material is based upon work supported by the Defense Advanced Research Projects Agency (DARPA) under contract FA8650-15-C-7557.


  1. 1.
    Abu-Aisheh, Z., et al.: Graph edit distance contest: results and future challenges. Pattern Recogn. Lett. 100, 96–103 (2017)CrossRefGoogle Scholar
  2. 2.
    Abu-Aisheh, Z., Raveaux, R., Ramel, J.-Y., Martineau, P.: An exact graph edit distance algorithm for solving pattern recognition problems. In: Proceedings of the International Conference on Pattern Recognition Applications and Methods (ICPRAM 2015), pp. 271–278 (2015)Google Scholar
  3. 3.
    Abu-Aisheh, Z., Raveaux, R., Ramel, J.-Y., Martineau, P.: A parallel graph edit distance algorithm. Expert Syst. Appl. 94, 41–57 (2018)CrossRefGoogle Scholar
  4. 4.
    Arvind, V., Torán, J.: Isomorphism testing: perspectives and open problems. Bull. EATCS 86, 66–84 (2005)MathSciNetzbMATHGoogle Scholar
  5. 5.
    Auer, S., Bizer, C., Kobilarov, G., Lehmann, J., Cyganiak, R., Ives, Z.: DBpedia: a nucleus for a web of open data. In: Aberer, K., et al. (eds.) ASWC/ISWC -2007. LNCS, vol. 4825, pp. 722–735. Springer, Heidelberg (2007). Scholar
  6. 6.
    Bunke, H.: On a relation between graph edit distance and maximum common subgraph. Pattern Recogn. Lett. 18(8), 689–694 (1997)MathSciNetCrossRefGoogle Scholar
  7. 7.
    Chan, S.C., Cheney, J.: Flexible graph matching and graph edit distance using answer set programming (extended version). CoRR, abs/1911.11584 (2019)Google Scholar
  8. 8.
    Chan, S.C., et al.: ProvMark: a provenance expressiveness benchmarking system. In: Proceedings of the 20th International Middleware Conference (Middlware 2019), pp. 268–279. ACM (2019)Google Scholar
  9. 9.
    Chen, X., Huo, H., Huan, J., Vitter, J.S.: An efficient algorithm for graph edit distance computation. Knowl.-Based Syst. 163, 762–775 (2019)CrossRefGoogle Scholar
  10. 10.
    Frank, M., Codish, M.: Logic programming with graph automorphism: integrating nauty with prolog (tool description). TPLP 16(5–6), 688–702 (2016)MathSciNetzbMATHGoogle Scholar
  11. 11.
    Gao, X., Xiao, B., Tao, D., Li, X.: A survey of graph edit distance. Pattern Anal. Appl. 13(1), 113–129 (2010)MathSciNetCrossRefGoogle Scholar
  12. 12.
    Garey, M.R., Johnson, D.S.: Computers and Intractability: A Guide to the Theory of NP-Completeness. W. H. Freeman, New York (1979)zbMATHGoogle Scholar
  13. 13.
    Gebser, M., et al.: The potsdam answer set solving collection 5.0. KI-Künstliche Intelligenz 32(2–3), 181–182 (2018)CrossRefGoogle Scholar
  14. 14.
    Gebser, M., Kaufmann, B., Kaminski, R., Ostrowski, M., Schaub, T., Schneider, M.T.: Potassco: the Potsdam answer set solving collection. AI Commun. 24(2), 107–124 (2011)MathSciNetCrossRefGoogle Scholar
  15. 15.
    Kazius, J., McGuire, R., Bursi, R.: Derivation and validation of toxicophores for mutagenicity prediction. J. Med. Chem. 48(1), 312–320 (2005)CrossRefGoogle Scholar
  16. 16.
    Lee, J., Han, W.-S., Kasperovics, R., Lee, J.-H.: An in-depth comparison of subgraph isomorphism algorithms in graph databases. PVLDB 6(2), 133–144 (2012)Google Scholar
  17. 17.
    Lerouge, J., Abu-Aisheh, Z., Raveaux, R., Héroux, P., Adam, S.: New binary linear programming formulation to compute the graph edit distance. Pattern Recogn. 72, 254–265 (2017)CrossRefGoogle Scholar
  18. 18.
    McKay, B.D.: Practical graph isomorphism. Congressus Numerantium 30, 45–87 (1981)MathSciNetzbMATHGoogle Scholar
  19. 19.
    McKay, B.D., Piperno, A.: Practical graph isomorphism, II. J. Symb. Comput. 60, 94–112 (2014)MathSciNetCrossRefGoogle Scholar
  20. 20.
    Pasquier, T., et al.: Practical whole-system provenance capture. In: Proceedings of the 2017 Symposium on Cloud Computing (SoCC 2017), pp. 405–418 (2017)Google Scholar
  21. 21.
    Riesen, K.: Structural Pattern Recognition with Graph Edit Distance - Approximation Algorithms and Applications. Springer, Cham (2015). Scholar
  22. 22.
    Zampelli, S., Deville, Y., Dupont, P.: Approximate constrained subgraph matching. In: Proceedings of the 11th International Conference on Principles and Practice of Constraint Programming (CP 2005), pp. 832–836 (2005)CrossRefGoogle Scholar

Copyright information

© Springer Nature Switzerland AG 2020

Authors and Affiliations

  1. 1.University of EdinburghEdinburghUK
  2. 2.The Alan Turing InstituteLondonUK

Personalised recommendations