Any working example of VF2 algorithm?

I am not sure that's what you're looking for, but the VF2 algorithm proceeds as below.

Let's say you have 2 graphs: V and V' and you want to match V with V'

The algorithm goes down a tree, at each step you try to match a next element of V with one of V' and you stop when you went through all the nodes in V' (when you find a leaf).

Algorithm:

  • First step : match empty V with empty graph V'.
  • Second step : try to match one node in V with one node in V'
  • ...
  • Nth step : try to match one node in V with one new node in V', if you cannot go back one step in the tree and try a new match in the previous step.. and if you cant go back again etc...
  • ...
  • END : when you find a leaf, i.e when you went through all the nodes in V' or when you went through the whole tree without finding a leaf.

Example

Here is a example, the algorithm proceeds from left to right of the tree.

"A <-> B" means Match node A of V with node B of V'

enter image description here

Hope I'm clear and that's what your looking for.


I've written a high-level overview of VF2, and also a fairly compact from-scratch Java implementation for cheminformatics.