VF2 algorithm steps with example

Abdul Samad picture Abdul Samad · Nov 18, 2011 · Viewed 9.4k times · Source

Can someone explain the steps of the VF2 algorithm for graph isomorphism in simple words? I am learning this algorithm, but it is harsh without a working example. Can someone lead me the right direction? Thank you.

Answer

Ricky Bobby picture Ricky Bobby · Nov 18, 2011

I will try to give you a quick explaination of my previous answer to this question :

Any working example of VF2 algorithm?

I will use the same example as the one in my previous answer :

enter image description here

The 2 graphs above are V and V' .(V' is not in the drawing but it's the one on the right)

The VF2 algorithm is described in the graph.

Step by step

I want to know if V and V' are isomorphic.

I will use the following notations : XV is the node X in V

In the VF2 algorithm I will try to match each node in V with a node in V'.

step 1 :

I match empty V with empty V' : it always works

step 2 : I can match 1V with 1V',2V' or 3V'

I match 1V with 1V' : it always works

step 3 :

I can match 2V with 2V' or 3V'

I match 2V with 2V' : it works because {1V 2V} and {1V' 2V} are isomorphic

step 4 :

I try to match 3V with a node in V' : I cannot! {it would be possible if there were an edge between node 3 and 2 in V', and no edge between 3 and 1)

So I go back to step 2

step 5:

I match 2V with 3V'

step 6:

same as step 4

I go back to step 2. there is no solution in step 2 , I go back to step 1

step 7:

I match 1V with 2V'

step 8:

I match 2V with 1V'

step 9 :

I match 3V with 3V'

it works I matched {1V 2V 3V} with { 2V' 1V' 3V'}

The graphs are isomorphic.

If I test all the solution and it never works the graph would not be isomorphic.

Hope this helps


About your question on "matching", have a look at the wikipedia article on graph isomorphism :

http://en.wikipedia.org/wiki/Graph_isomorphism

this is a good example of a function f that matches graph G and H : enter image description here

Hope you can better understand this algorithm with this illustration.