# A Polynomial-Time Algorithm for Computing the Maximum Common Connected Edge Subgraph of Outerplanar Graphs of Bounded Degree

^{*}

## Abstract

**:**

## 1. Introduction

## 2. Preliminaries

**Example**Figure 1 shows an example of an outerplanar graph $G(V,E)$. Blocks and bridges are shown by gray regions and bold lines, respectively. ${B}_{1}$, ${B}_{3}$ and ${e}_{2}$ are the children of the root r. ${B}_{4}$, ${B}_{6}$ and ${B}_{7}$ are the children of ${B}_{3}$, whereas ${B}_{4}$ and ${B}_{6}$ are the children of w. Both w and ${B}_{3}$ are the parents of ${B}_{4}$ and ${B}_{6}$. $G\left(w\right)$ consists of ${B}_{4}$, ${B}_{5}$ and ${B}_{6}$, whereas $G(w,{B}_{4})$ consists of ${B}_{4}$ and ${B}_{5}$. $(v,{v}^{\prime})$ is a cut pair of ${B}_{7}$, and ${B}_{7}(v,{v}^{\prime})$ is a region surrounded by a dashed bold curve. $\overline{G}(v,{v}^{\prime})$ consists of ${B}_{7}(v,{v}^{\prime})$, ${B}_{8}$, ${B}_{9}$, ${B}_{10}$, ${e}_{4}$, ${e}_{5}$ and ${e}_{6}$, whereas $G(v,{v}^{\prime})$ consists of ${B}_{7}(v,{v}^{\prime})$, ${B}_{10}$, ${e}_{4}$ and ${e}_{5}$.

**Maximum Common Subgraph of Outerplanar Graphs of Bounded Degree**(OUTER-MCS)

**Fact 1**Let ${G}_{1}$ and ${G}_{2}$ be biconnected outerplanar graphs. Let $({u}_{1},{u}_{2},\dots ,{u}_{m})$ (resp. $({v}_{1},{v}_{2},\dots ,{v}_{n})$) be the vertices of ${G}_{1}$ (resp. ${G}_{2}$) arranged in clockwise order in a planar embedding of ${G}_{1}$ (resp. ${G}_{2}$). If there is an isomorphic mapping $\{({u}_{1},{v}_{{i}_{1}}),({u}_{2},{v}_{{i}_{2}}),\dots ,({u}_{m},{v}_{{i}_{m}})\}$ from ${G}_{1}$ to a subgraph of ${G}_{2}$, then ${v}_{{i}_{1}},{v}_{{i}_{2}},\dots ,{v}_{{i}_{m}}$ appear in ${G}_{2}$ in either clockwise or counterclockwise order.

## 3. Algorithm for a Restricted Case

**for all**pairs of vertices $(u,v)\in {V}_{1}\times {V}_{2}$

**do**

**return**${s}_{max}$.

- $MC{S}_{c}({G}_{1}\left(u\right),{G}_{2}\left(v\right))$:
- the size of an MCS ${G}_{c}$ between ${G}_{1}\left(u\right)$ and ${G}_{2}\left(v\right)$, where $(u,v)$ is a pair of the roots or a pair of cut vertices, and ${G}_{c}$ must contain a vertex corresponding to both u and v.
- $MC{S}_{b}({G}_{1}(u,C),{G}_{2}(v,D))$:
- the size of an MCS ${G}_{c}$ between ${G}_{1}(u,C)$ and ${G}_{2}(v,D)$, where $(C,D)$ is either a pair of blocks or a pair of bridges, u (resp. v) is the cut vertex belonging to both C (resp. D) and its parent, ${G}_{c}$ must contain a vertex corresponding to both u and v and ${G}_{c}$ must contain a biconnected component (which can be empty) corresponding to a subgraph of C and a subgraph D.
- $MC{S}_{p}({G}_{1}(u,{u}^{\prime}),{G}_{2}(v,{v}^{\prime}))$:
- the size of an MCS ${G}_{c}$ between ${G}_{1}(u,{u}^{\prime})$ and ${G}_{2}(v,{v}^{\prime})$, where $(u,{u}^{\prime})$ (resp. $(v,{v}^{\prime})$) is a cut pair, and ${G}_{c}$ must contain a cut pair $(w,{w}^{\prime})$ corresponding to both $(u,{u}^{\prime})$ and $(v,{v}^{\prime})$. If there does not exist such ${G}_{c}$ (which must be connected), its score is $-\infty $.

**Computation of**$MC{S}_{c}({G}_{1}\left(u\right),{G}_{2}\left(v\right))$

**Computation of**$MC{S}_{b}({G}_{1}(u,C),{G}_{2}(v,D))$

**for all**alignments $(({u}_{{i}_{1}},{u}_{{i}_{2}},\dots ,{u}_{{i}_{g}}),({v}_{{j}_{1}},{v}_{{j}_{2}},\dots ,{v}_{{j}_{g}}))$

**do**;

**if**C is a block and $g=1$

**then**

**continue**; /* blocks must be preserved */

**for**$t=1$

**to**g

**do**$s\leftarrow s+1+MC{S}_{c}({G}_{1}({u}_{{i}_{t}}),{G}_{2}({v}_{{j}_{t}}))$;

**for**$t=2$

**to**g

**do**$s\leftarrow s+MC{S}_{p}({G}_{1}({u}_{{i}_{t-1}},{u}_{{i}_{t}}),{G}_{2}({v}_{{j}_{t-1}},{v}_{{j}_{t}}))$;

**return**${s}_{max}$.

**for**loop takes care of blocks, such as ${C}_{1}$, ${C}_{4}$, ${D}_{1}$ and ${D}_{4}$ in Figure 3, whereas the second inner

**for**loop takes care of half blocks, such as ${C}_{2}$, ${C}_{3}$, ${D}_{2}$, ${D}_{3}$ and ${D}_{5}$ in Figure 3.

**if**...

**then**...” line of the procedure, because a bridge in ${G}_{c}$, which would correspond to $\{u,{u}_{1}\}$ in ${G}_{1}$ and $\{v,{v}_{1}\}$ in ${G}_{2}$, must not be mapped to an edge in C or D. However, if both $\{u,{u}_{1}\}$ and $\{v,{v}_{1}\}$ are bridges, the resulting score would be $1+MC{S}_{c}({G}_{1}\left({u}_{1}\right),{G}_{2}\left({v}_{1}\right))$.

**for**loop, $M[s,t]$ stores the size of MCS between ${G}_{1}\left({u}_{s}\right)$ and ${G}_{2}\left({v}_{t}\right)$ plus one (corresponding to a common edge between $\{u,{u}_{s}\}$ and $\{v,{v}_{t}\}$). The double

**for**loop computes an optimal alignment. $M[s,t]$ stores the size of MCS between ${G}_{1}(u,C)$ and ${G}_{2}(v,D)$ up to ${u}_{s}$ and ${v}_{t}$, respectively. $flag$ is introduced to ensure the connectedness of a common subgraph. For example, $flag=0$ if ${G}_{1}\left(u\right)$ is a triangle, but ${G}_{2}\left(v\right)$ is a rectangle. If C (and also D) is an edge, $flag=0$, but the procedure returns $M[1,1]$.

**for all**$(s,t)\in \{1,\dots ,h\}\times \{1,\dots ,k\}$

**do**

**for**$s=2$ to h

**do**

**for**$t=2$ to k

**do**

**if**$M[s,t]>-\infty $

**then**$flag\leftarrow 1$;

**if**C is a block and $flag=0$

**then**

**return**0

**else**

**return**${max}_{s,t}M[s,t]$.

**Computation of**$MC{S}_{p}({G}_{1}(u,{u}^{\prime}),{G}_{2}(v,{v}^{\prime}))$

**if**$\{u,{u}^{\prime}\}\in {E}_{1}$ and $\{v,{v}^{\prime}\}\in {E}_{2}$

**then**${s}_{max}\leftarrow 1$

**else**${s}_{max}\leftarrow -\infty $;

**for all**alignments $(({u}_{{i}_{1}},{u}_{{i}_{2}},\dots ,{u}_{{i}_{g}}),({v}_{{j}_{1}},{v}_{{j}_{2}},\dots ,{v}_{{j}_{g}}))$

**do**

**if**$l({u}_{{i}_{t}},{v}_{{j}_{t}})=0$ and $r({u}_{{i}_{t}},{v}_{{j}_{t}})=0$ hold for some t

**then**

**continue**;

**if**$l({u}_{{i}_{1}},{v}_{{j}_{1}})=0$ or $r({u}_{{i}_{g}},{v}_{{j}_{g}})=0$ holds

**then**

**continue**;

**if**$\{u,{u}^{\prime}\}\in {E}_{1}$ and $\{v,{v}^{\prime}\}\in {E}_{2}$

**then**$s\leftarrow 1$

**else**$s\leftarrow 0$;

**for**$t=1$

**to**g

**do**$s\leftarrow s+l({u}_{{i}_{t}},{v}_{{j}_{t}})+r({u}_{{i}_{t}},{v}_{{j}_{t}})+MC{S}_{c}({G}_{1}\left({u}_{{i}_{t}}\right),{G}_{2}\left({v}_{{j}_{t}}\right))$;

**for**$t=2$

**to**g

**do**$s\leftarrow s+MC{S}_{p}({G}_{1}({u}_{{i}_{t-1}},{u}_{{i}_{t}}),{G}_{2}({v}_{{j}_{t-1}},{v}_{{j}_{t}}))$;

**return**${s}_{max}$.

**Theorem 1**SIMPLE-OUTER-MCS can be solved in polynomial time.

## 4. Algorithm for Outerplanar Graphs of Bounded Degree

- both $\{{v}_{{i}_{1}},{v}_{{i}_{k}}\}$ and $\{{v}^{\prime},{v}_{{i}_{1}}\}$ are deleted
- $\{{v}_{{i}_{1}},{v}_{{i}_{k}}\}$ is deleted, but $\{{v}^{\prime},{v}_{{i}_{1}}\}$ remains
- both $\{{v}_{{i}_{1}},{v}_{{i}_{k}}\}$ and $\{{v}^{\prime},{v}_{{i}_{1}}\}$ remain

**Figure 6.**(

**A**) Construction of blades where subgraphs, excluding gray regions (descendant components), are blade bodies; and (

**B**) schematic illustration of a blade.

**Figure 7.**Types and subcases of blades, where two other subcases for (ii) and another subcase (i.e., $\{{v}^{\prime},{v}_{{i}_{1}}\}$ remains) for (iii) and (iv) are omitted.

**Figure 8.**Example of configuration and its resulting subgraph of ${G}_{1}\left(u\right)$. Black circles, dark gray regions and thin dotted lines denote selected vertices, blades and removed edges, respectively. Block ${C}_{1}$ and edges ${e}_{1},{e}_{2}$ are the children of u in ${G}_{1}\left(u\right)$, where block ${H}_{1}$ is a child of ${e}_{1}$, blocks ${H}_{2},{H}_{3}$ are children of ${C}_{1}$ and block ${H}_{4}$ is a child of ${e}_{2}$. Edges, ${e}_{a},{e}_{b}$, are tip edges, where $\{u,{u}_{5}\}$ is also regarded as a tip edge. Then, edge ${e}_{1}$ is deleted along with block ${H}_{1}$, whereas edge ${e}_{2}$ remains as it is. Block ${C}_{1}$ is divided into block ${C}_{1}^{\prime}$, blades ${B}_{1},\dots ,{B}_{5}$ and edge ${e}_{1}^{\prime}$, where blocks, ${H}_{2},{H}_{3}$, and blades, ${B}_{1},{B}_{2},{B}_{3}$, are children of ${C}_{1}^{\prime}$ and blades, ${B}_{4},{B}_{5}$, are children of ${e}_{1}^{\prime}$. In the resulting subgraph, block, ${C}_{1}^{\prime}$, and edges, ${e}_{1}^{\prime},{e}_{2}^{\prime}$, are the children of u.

#### 4.1. Description of Algorithm

**Computation of $MC{S}_{c}({G}_{1}\left(u\right),{G}_{2}\left(v\right))$**

- $s\left({u}_{{i}_{j}}\right)\in \{0,1\}$ for $j=1,\dots ,k$:
- $s\left({u}_{{i}_{j}}\right)=1$ means that ${u}_{{i}_{j}}$ is selected as a neighbor of u in a common subgraph, otherwise $s\left({u}_{{i}_{j}}\right)=0$. ${u}_{{i}_{j}}$ is called a selected vertex if $s\left({u}_{{i}_{j}}\right)=1$.
- $tip({u}_{{i}_{j}},{u}_{{i}_{k}})$:
- $e=tip({u}_{{i}_{j}},{u}_{{i}_{k}})$ is an edge in $B({u}_{{i}_{j}},{u}_{{i}_{k}})$, where B is the block containing ${u}_{{i}_{j}}$, ${u}_{{i}_{k}}$ and u. This edge is defined only for a consecutive selected vertex pair, ${u}_{{i}_{j}}$ and ${u}_{{i}_{k}}$, in the same block (i.e., $B({u}_{{i}_{j}},{u}_{{i}_{k}})$ does not contain any other selected vertex). e is used as a tip edge, where e can be empty, which means that we do not cut any edge in $B({u}_{{i}_{j}},{u}_{{i}_{k}})$. It is to be noted that, at most, one edge in $B({u}_{{i}_{j}},{u}_{{i}_{k}})$ can be a tip edge, and thus, each $B({u}_{{i}_{j}},{u}_{{i}_{k}})$ is divided into, at most, two blade bodies; further decomposition will be done in later steps. We also consider $\overline{e}$ and $\widehat{e}$ for $e=tip({u}_{{i}_{j}},{u}_{{i}_{k}})$ whenever available.

- ${e}_{i}=\{{u}_{{i}_{j}},u\}$ ($i\in \{1,\dots ,{h}_{2}\}$) remains if $s\left({u}_{{i}_{j}}\right)=1$. Otherwise, ${e}_{i}$ is removed along with its descendants.
- If no vertex in ${C}_{i}$ is selected, it is removed along with its descendants. Otherwise, ${C}_{i}$ is divided into blocks, blade bodies (according to $s(\dots )$’s and $tip(\dots )$’s) and bridges, where edges, $\{{u}_{{i}_{j}},u\}$ with $s\left({u}_{{i}_{j}}\right)=0$, are removed.

**for all**configurations ${F}_{1}$ for ${G}_{1}\left(u\right)$

**do**

**for all**configurations ${F}_{2}$ for ${G}_{2}\left(v\right)$

**do**

**if**$s>{s}_{max}$

**then**${s}_{max}\leftarrow s$;

**return**${s}_{max}$.

**Computation of $MC{S}_{b}({G}_{1}(u,{C}^{\prime}),{G}_{2}(v,{D}^{\prime}))$**

**Computation of $MC{S}_{p}({G}_{1}(u,{u}^{\prime}),{G}_{2}(v,{v}^{\prime}))$**

- (i)
- components connecting only to u (resp. v)
- (ii)
- components connecting only to ${u}^{\prime}$ (resp. ${v}^{\prime}$) and
- (iii)
- component connecting to both u and ${u}^{\prime}$ (resp. v and ${v}^{\prime}$), where this type (iii) component is uniquely determined.

**Figure 9.**Example of configuration and its resulting subgraph for ${G}_{1}(u,{u}^{\prime})$. Black circles, dark gray regions and thin dotted lines denote selected vertices, blade, and removed edges, respectively. Edges, ${e}_{a},{e}_{b}$, are tip edges, where $\{{u}^{\prime},{u}^{\prime \prime}\}$ is also regarded as a tip edge. In the resulting subgraph, ${C}_{1}^{\prime}$ is a type (i) component, ${e}_{1}^{\prime}$ and ${e}_{2}^{\prime}$ are type (ii) components and ${C}_{0}(u,{u}^{\prime})$ is a type (iii) component.

**for all**configurations ${F}_{1}$ for ${G}_{1}(u,{u}^{\prime})$

**do**

**for all**configurations ${F}_{2}$ for ${G}_{2}(v,{v}^{\prime})$

**do**

**if**$s>{s}_{max}$

**then**${s}_{max}\leftarrow s$;

**return**${s}_{max}$.

#### 4.2. Analysis

**Lemma 1**The number of different half blocks and blades appearing in $OuterMCS({G}_{1},{G}_{2})$ is $O\left({n}^{2}\right)$.

- (a)
- w is not selected.The base vertex of a new blade is the selected vertex nearest to w in the first block (i.e., block containing u) of $BD$. Since the original blade body was a half block of a block ${C}_{0}$, the resulting blade body is also a half block of ${C}_{0}$.
- (b)
- w is selected, and there is no tip edge between w and its nearest selected vertex.The resulting blade body begins from w (in the next step), which is a half block of ${C}_{0}$.
- (c)
- w is selected, and there is a tip edge between w and its nearest selected vertex.The resulting blade body begins from w, which is a half block of ${C}_{0}$. Furthermore, two (or less) new blade bodies are created, both of which are half blocks of ${C}_{0}$.

**Figure 10.**Three cases considered in the proof of Lemma 1. Bold lines and dark gray regions denote backbone edges and new blade bodies, respectively.

**Theorem 2**A maximum common connected edge subgraph of two outerplanar graphs of bounded degree can be computed in polynomial-time.

## 5. Concluding Remarks

## Acknowledgments

## References

- Conte, D.; Foggia, P.; Sansone, C.; Vento, M. Thirty years of graph matching in pattern recognition. Int. J. Pattern Recognit. Artif. Intell.
**2004**, 18, 265–298. [Google Scholar] [CrossRef] - Shearer, K.; Bunke, H.; Venkatesh, S. Video indexing and similarity retrieval by largest common subgraph detection using decision trees. Pattern Recognit.
**2001**, 34, 1075–1091. [Google Scholar] [CrossRef] - Raymond, J.W.; Willett, P. Maximum common subgraph isomorphism algorithms for the matching of chemical structures. J. Comput. Aided Mol. Des.
**2002**, 16, 521–533. [Google Scholar] [CrossRef] [PubMed] - Hans-Christian Ehrlich, H-C.; Rarey, M. Maximum common subgraph isomorphism algorithms and their applications in molecular science: A review. WIREs Comput. Mol. Sci.
**2011**, 1, 68–79. [Google Scholar] - Abu-Khzam, F.N.; Samatova, N.F.; Rizk, M.A.; Langston, M.A. The Maximum Common Subgraph Problem: Faster Solutions via Vertex Cover. In Proceedings of the 2007 IEEE/ACS International Conference Computer Systems and Applications, IEEE; Piscataway, NJ, USA, 2007; pp. 367–373. [Google Scholar]
- Huang, X.; Lai, J.; Jennings, S.F. Maximum common subgraph: Some upper bound and lower bound results. BMC Bioinforma.
**2006**, 7 (Suppl. 4), S6:1–S6:9. [Google Scholar] [CrossRef] [PubMed] - Kann, V. On the Approximability of the Maximum Common Subgraph Problem. In Proceedings of the 9th Symposium Theoretical Aspects of Computer Science; Springer: Heidelberg, Germany, 1992; Volume 577, pp. 377–388. [Google Scholar]
- Garey, M.R.; Johnson, D.S. Computers and Intractability; Freeman: New York, NY, USA, 1979. [Google Scholar]
- Akutsu, T. A polynomial time algorithm for finding a largest common subgraph of almost trees of bounded degree. IEICE Trans. Fundam.
**1993**, E76-A, 1488–1493. [Google Scholar] - Yamaguchi, A.; Aoki, K.F.; Mamitsuka, H. Finding the maximum common subgraph of a partial k-tree and a graph with a polynomially bounded number of spanning trees. Inf. Proc. Lett.
**2004**, 92, 57–63. [Google Scholar] [CrossRef] - Schietgat, L.; Ramon, J.; Bruynooghe, M. A Polynomial-Time Metric for Outerplanar Graphs. In Proceedings of the Workshop on Mining and Learning with Graphs, Firenze, Italy, 1 August 2007.
- Bachl, S.; Brandenburg, F-J.; Gmach, D. Computing and drawing isomorphic subgraphs. J. Graph Algorithms Appl.
**2004**, 8, 215–238. [Google Scholar] [CrossRef] - Lingas, A. Subgraph isomorphism for biconnected outerplanar graphs in cubic time. Theoret. Comput. Sci.
**1989**, 63, 295–302. [Google Scholar] [CrossRef] - Syslo, M.M. The subgraph isomorphism problem for outerplanar graphs. Theoret. Comput. Sci.
**1982**, 17, 91–97. [Google Scholar] [CrossRef] - Dessmark, A.; Lingas, A.; Proskurowski, A. Faster algorithms for subgraph isomorphism of k-connected partial k-trees. Algorithmica
**2000**, 27, 337–347. [Google Scholar] [CrossRef] - Hajiaghayi, M.; Nishimura, N. Subgraph isomorphism, log-bounded fragmentation, and graphs of (locally) bounded treewidth. J. Comput. Syst. Sci.
**2007**, 73, 755–768. [Google Scholar] [CrossRef] - Akutsu, T.; Tamura, T. A Polynomial-Time Algorithm for Computing the Maximum Common Subgraph of Outerplanar Graphs of Bounded Degree. In Proceedings of the 37th International Symposium on Mathematical Foundations of Computer Science; Springer: Heidelberg, Germany, 2012; Volume 7464, pp. 76–87. [Google Scholar]
- Horváth, T.; Ramon, J.; Wrobel, S. Frequent Subgraph Mining in Outerplanar Graphs. In Proceedings of the 12th ACM SIGKDD Int. Conf. Knowledge Discovery and Data Mining; ACM: New York, NY, USA, 2006; pp. 197–206. [Google Scholar]
- Akutsu, T. An RNC algorithm for finding a largest common subtree of two trees. IEICE Trans. Inf. Syst.
**1992**, E75-D, 95–101. [Google Scholar] - Syslo, M.M. Characterizations of outerplanar graphs. Disc. Math.
**1979**, 26, 47–53. [Google Scholar] [CrossRef] - Chartrand, G.; Lesniak, L.; Zhang, P. Graphs and Digraphs, Fifth Edition; Chapman and Hall/CRC: Boca Raton, FL, USA, 2010. [Google Scholar]
- Cormen, T.H.; Leiserson, C.E.; Rivest, R.L.; Stein, C. Introduction to Algorithms, Third Edition; The MIT Press: Cambridge, MA, USA, 2009. [Google Scholar]
- Akutsu, T.; Tamura, T. On the Complexity of the Maximum Common Subgraph Problem for Partial k-trees of Bounded Degree. In Proceedings of the 23rd International Symposium Algorithms and Computation; Springer: Heidelberg, Germany, 2012; Volume 7676, pp. 146–155. [Google Scholar]

© 2013 by the authors; licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution license (http://creativecommons.org/licenses/by/3.0/).

## Share and Cite

**MDPI and ACS Style**

Akutsu, T.; Tamura, T. A Polynomial-Time Algorithm for Computing the Maximum Common Connected Edge Subgraph of Outerplanar Graphs of Bounded Degree. *Algorithms* **2013**, *6*, 119-135.
https://doi.org/10.3390/a6010119

**AMA Style**

Akutsu T, Tamura T. A Polynomial-Time Algorithm for Computing the Maximum Common Connected Edge Subgraph of Outerplanar Graphs of Bounded Degree. *Algorithms*. 2013; 6(1):119-135.
https://doi.org/10.3390/a6010119

**Chicago/Turabian Style**

Akutsu, Tatsuya, and Takeyuki Tamura. 2013. "A Polynomial-Time Algorithm for Computing the Maximum Common Connected Edge Subgraph of Outerplanar Graphs of Bounded Degree" *Algorithms* 6, no. 1: 119-135.
https://doi.org/10.3390/a6010119