Reputation: 19958
Disclaimer: I'm a total newbie at graph theory and I'm not sure if this belongs on SO, Math SE, etc.
Given 2 adjacency matrices A and B, how can I determine if A and B are isomorphic.
For example, A and B which are not isomorphic and C and D which are isomorphic.
A = [ 0 1 0 0 1 1 B = [ 0 1 1 0 0 0
1 0 1 0 0 1 1 0 1 1 0 0
0 1 0 1 0 0 1 1 0 1 1 0
0 0 1 0 1 0 0 1 1 0 0 1
1 0 0 1 0 1 0 0 1 0 0 1
1 1 0 0 1 0 ] 0 0 0 1 1 0 ]
C = [ 0 1 0 1 0 1 D = [ 0 1 0 1 1 0
1 0 1 0 0 1 1 0 1 0 1 0
0 1 0 1 1 0 0 1 0 1 0 1
1 0 1 0 1 0 1 0 1 0 0 1
0 0 1 1 0 1 1 1 0 0 0 1
1 1 0 0 1 0 ] 0 0 1 1 1 0 ]
(sorry for this ugly notation, I'm not quite sure how to draw matrices on SO)
Here's how I've started my algorithm (pardon my lack of mathematical rigor) please help me complete/correct!
Upvotes: 13
Views: 21293
Reputation: 1
In general, it is not a simple task to prove that two graphs are isomorphic. For that reason we must consider some properties of isomorphic graphs. That means those properties must be satisfied if the graphs are isomorphic. If the given graph does not satisfy these properties then we can say they are not isomorphic graphs.
Property: Two graphs are isomorphic if and only if for some ordering of their vertices their adjacency matrices are equal.
Based on the above property we can decide whether the given graphs are isomorphic or not. In order to check the property, we need to do some matrix transformation operations.
Upvotes: 0
Reputation: 862
Well, it is very easy to quickly tell that they ARE NOT isomorphic by doing the following.
areIsomorphic(G1, G2):
if(G1.num_verticies != G2.num_verticies)
return False
if(G1.num_total_edges != G2.num_total_edges)
return False
for each vertex v in G1:
if( G2.find(v).edges != v.edges):
return False;
//Try and find a property in graph G1 that does not exist in G2.
// Use a heuristic. ie- try and find nonmutually adjacenct sets.
Upvotes: 1
Reputation: 219
My project - Griso - at sf.net: http://sourceforge.net/projects/griso/ with this description:
Griso is a graph isomorphism testing utility written in C++ and based on my own algo.
See Griso's sample input/output on this page: http://funkybee.narod.ru/graphs.htm
Upvotes: 6
Reputation: 839254
That's a quite difficult problem to solve. There is a Wikipedia page about it:
According to that page there are a number of special cases that have been solved with efficient polynomial time solutions, but the complexity of the optimal solution is still unknown.
Upvotes: 10