back to the VF home page
This document describes a preliminary release of the C++ implementation of VF, an efficient graph isomorphism algorithm decribed in [1]. We provide this release for allowing tests of the performance of our algorithm and comparisons with other algorithms. For this reason, we have included in this distribution an implementation of Ullman's algorithm [2].
Since the porting from Prolog to C++ is still in progress, this release is not yet complete. In particular, the following features will be added in the next release:
This software has been developed by the Artificial Vision Group of the "Federico II" University of Naples, Italy. For more information, please send a letter or an e-mail to:
Università degli Studi di Napoli "FedericoII"
Dipartimento di Informatica e Sistemistica
The software has been tested on a SPARCStation 20 with SunOS 4.1.3 and gcc 2.3.3, and on a PC with Linux 2.0.0 and gcc 2.7.2.
The C and C++ files should be portable on other operative systems.
After unpacking the file sources.tgz using the command
gunzip -c sources.tgz | tar xvf -
in the proper directory, you should edit the file Makefile according to your system configuration. Then you can compile with the command make.
After the compilation, if no error occurs, you will have 3 executable programs: matcher, ull_matcher and gene.
The software provided consists of 3 programs, matcher, ull_matcher and gene, and some nawk scripts to partially automate the testing phase. Each of these programs is described in one of the following subsections.
These programs perform a graph matching using VF and Ullman's algorithm. They can either find and display the first isomorphism between two graphs, or find all the existing isomorphisms, printing only the overall time spent in the matching process. The input graphs are represented by means of their adjacency matrices, specified as text files using the format:
N
A11 A12 ... A1n
A21 A22 ... A2n
...
An1 An2 ... Ann
where N is the number of nodes, and Aij is 1 if there is a branch from node i to node j, 0 otherwise.
The usage of the programs is:
matcher [all] file_1 file_2 [rep]
where the keyword all is used to find all the isomorphisms, and rep is a repetition count, used to repeat the matching operations for a number of times sufficient to require a time interval which can be measured with enough precision by the system clock. The usage of ull_matcher requires the same parameters.
Examples of invocations of this programs are:
amalfi% matcher graph1 graph2 100
-Found match: (0,13) (1,0) (2,7) (3,16) (4,1) (5,18) (6,5) (7,17) (8,19) (9,9) (10,12) (11,11) (12,3) (13,14) (14,8) (15,4) (16,2) (17,6) (18,15) (19,10)
+Time: 0.820 sec
amalfi% matcher all graph1 graph2
-Found 2 matches
+Time: 0.110 sec
This program is used to randomly generate pairs of isomorphic graphs with a given number of nodes and branches. It ensures that the resulting graphs are connected, adding more branches than requested if necessary. The graphs are stored in text files using the format described in the previous subsection.
The usage of the program is:
gene num_nodes num_branches file_1 file_2
This program generates a shell script for performing a test of the two matching algorithms (ours and Ullman's).
The usage is:
nawk -f genbatch.awk node_file branch_file > script_file
where:
node_file is the name of a text file containing the number of nodes to be used. Each line contains a number of nodes and a corresponding repeat count.
branch_file is the name of a text file containing the ratios of branches to be used. Each line contains a real number in [0,1] which is the ratio between the desired number of branches and the square of the number of nodes
script_file is the test shell script. You must change by hand the permissions of this file, with
chmod ugo+x script_file
The script output by genbatch.awk tests every combination of number of nodes and number of branches, generating 125 graphs and applying the two algorithms. The results are written on standard output, which should be redirected to a file to be furtherly processed by mktable.awk
Example: using the following node_file:
40 20
50 10
and the following branch_file:
0.1
0.5
the generated script tests the following combinations of nodes, branches and repetitions:
|
nodes |
branches |
rep |
|
40 |
160 |
20 |
|
40 |
800 |
20 |
|
50 |
250 |
10 |
| 50 | 1250 | 10 |
This program examines the results of a shell script generated by genbatch.awk computing averages and standard devs for the matching times, and outputs a table with these data
Usage:
nawk -f mktable.awk script_output > result_table
Example:
Using the same node numbers and branch ratios of the example in the previous subsection, the resulting table is:
Branch ratio: 0.1 Algorithm: vf
40 0.00974 0.00120
50 0.01426 0.00108
Branch ratio: 0.1 Algorithm: ull
40 0.04680 0.00354
50 0.08346 0.00224
Branch ratio: 0.5 Algorithm: vf
40 0.02028 0.00332
50 0.03266 0.00535
Branch ratio: 0.5 Algorithm: ull
40 0.04543 0.00253
50 0.08580 0.00613
where the first column contains the number of nodes, and the other two the average time in seconds and its standard deviation.