<<

Graph and Related Problems Graph Isomorphism

Graph Isomorphism

Two graphs G1 = (V1, E1) and G2 = (V2, E2) are isomorphic if there is a bijection ϕ: V1 → V2 such that, for all u, v ∈ V1, uv ∈ E1 if and only if ϕ(u)ϕ(v) ∈ E2. Isomorphism of two graphs G1 and G2 is denoted as G1 ' G2.

2 / 10 Graph Isomorphism – Related Problems

Subgraph Isomorphism

I Determine if G is isomorphic to a subgraph of H.

Largest Common Subgraph

I For two given graphs G1 and G2, find the largest graph H such that H is isomorphic to a subgraph of G1 and to a subgraph of G2.

Theorem There is (probably) no polynomial time algorithm to solve the Subgraph Isomorphism problem.

c In 2015, Babai presented a proof that there is a O 2log n time algorithm to solve the Graph Isomorphism problem. (Result is not peer reviewed yet.)

3 / 10 Isomorphism of Trees Isomorphism of Trees

Centers

I A vertex v is center of G, if ecc(v) = rad(G).

I A has at most two centers which can be found in linear time. In case of two, both are adjacent.

Finding ceters in trees

I Pick an arbitrary vertex v. I Find a vertex x with d(v, x) = ecc(v). I Find a vertex y with d(x, y) = ecc(x). I Then, ecc(x) = ecc(y) = diam(T) and the vertices in the middle of the path from x to y are centers of T (two vertices if d(x, y) is odd, one vertex if d(x, y) is even).

Note: There is a linear time algorithm to compute the eccentricity of every vertex in a tree in linear time.

5 / 10 Isomorphism of Trees

Rooted Tree We say (V, E, r) is a tree with root r if (V, E) is a tree and r ∈ V.

Isomorphism of Rooted Trees

Two rooted trees T1 = (V1, E1, r1) and T2 = (V2, E2, r2) are isomorphic if there is a bijection ϕ: V1 → V2 such that, for all u, v ∈ V1, uv ∈ E1 if and only if ϕ(u)ϕ(v) ∈ E2 and ϕ(r1) = ϕ(r2).

T1 T2 T3

T1 and T3 are isometric. However, T2 is not isometric to T1 and T3.

6 / 10 Isomorphism of Trees

Theorem If there is an O(f (n)) time algorithm A to check if two rooted trees are isomorphic, then there is an O(f (n)) time algorithm A∗ to check if two ordinary trees are isomorphic.

∗ Proof: We design A (T1, T2) as follows: Find the centers of T1 and T2. Then, there are three cases.

C1 Both have only one center (c1 and c2). Retrun A(T1, c1, T2, c2) 0 0 C2 Both have two centers (c1, c1, c2, and c2). 0 Retrun A(T1, c1, T2, c2) ∨ A(T1, c1, T2, c2) C3 Different number of centers. Return False 

Therefore, it is enough if we can check rooted trees.

7 / 10 Aho-Hopcroft-Ullman-Algorithm

Let T1 and T2 be two rooted trees with corresponding roots r1 and r2. With Fi,j, we denote the forest created by removing all vertices v ∈ Ti with d(v, ri) ≤ j.

Theorem

T1 is isometric to T2 if and only if, for all i, F1,i is isometric to F2,i.

Algorithm idea:

I Check bottom-up if F1,i is isometric to F2,i. I Note: The lowest layer contains only leaves.

I Use that F1,i+1 is isometric to F2,i+1 when checking F1,i and F2,i.

8 / 10 Aho-Hopcroft-Ullman-Algorithm

Input: Two rooted trees T1 and T2 with the corresponding roots r1

and r2 and with height h.

1 Compute the depth of each vertex in T1 and T2.

2 To each leaf, assign the integer 0.

3 For i = h − 1 DownTo 1 4 hAssign integers to all nodes with depth i.i

5 T1 and T2 are isomorphic if and only if r1 and r2 have the same integer assigned.

9 / 10 Aho-Hopcroft-Ullman-Algorithm

1 Procedure AssignIntegers(i)

2 For Each v ∈ Vi (the set of non-leaf vertices with depth i)

3 Create a sorted tuple tv containing the integers assigned to the children of v.

4 Let S1 and S2 be the sets of tuples created for vertices in T1 and T2 with depth i.

5 Sort S1 and S2 lexicographically and compare them. If S1 6= S2,

Stop. T1 and T2 are not isomorphic.

6 Assign integers, continuously and beginning with 1, to vertices

in Vi such that two vertices have the same integer assigned if and only if they have equal tuples.

10 / 10