CAD/mathematics-MATLAB
Expert: George Moustris - 2/12/2007
Question
-------------------------------------------
The text above is a follow-up to ...
-----Question-----
I have two adjacency matrices representing two undirected graphs.
I want to check if they are isomorphic.
I have found that the function to use is
graphisomorphism(G1, G2), but it gives me errors,I think about the sparse array, in the way I define it
-----Answer-----
Hi Christiana,
i can't really help if you don't tell me what the problem is. What is the errors matlab produces? What are the matrices (G1,G2) you use?
Dear Sir,
I will give you a simpler question I have about MATLAB, instead of isomorphisms.
We have the following sets:
C1 = [1 2 3 4];
C2 = [1 3 5 6];
C3 = [2 4 7 8];
C4 = [4 6 10 12];
And also the sets
B1=[2 3 4 6 11 16];
B2=[1 3 4 5 7 8];
B3=[1 2 4 9 10 12];
B4=[1 2 3 13 14 15];
B5=[2 6 7 8 12 15];
B6=[1 5 11 12 15 16];
B7=[2 5 8 10 13 16];
B8=[2 5 7 9 11 14];
B9=[3 8 10 11 12 14];
B10=[3 7 9 12 13 16];
I want to check every one of the sets C1, C2, C3, C4 and find their intersection with the sets B1, B2,
, B10. More clearly
STEP1:
intersect(B1,C1)
intersect(B2,C1)
intersect(B3,C1)
intersect(B4,C1)
intersect(B5,C1)
intersect(B6,C1)
intersect(B7,C1)
intersect(B8,C1)
intersect(B9,C1)
intersect(B10,C1)
STEP2:
intersect(B1,C2)
intersect(B2,C2)
intersect(B3,C2)
intersect(B4,C2)
intersect(B5,C2)
intersect(B6,C2)
intersect(B7,C2)
intersect(B8,C2)
intersect(B9,C2)
intersect(B10,C2)
And so on
Can you help me with a source code for MATLAB, to use for loops in order to do this?
AnswerHi Christiana,
looping over matrices using their name as an index e,g, Ai, i=1,2,..., is not possible in Matlab. What you can do however is use cells. You can create a cell A which contains 4x10 matrices (4 C's (C1,C2 etc) and 10 B's) and reference them using the cell. For example A{1,1} is C1, A{2,1} is C2, A{1,2} is B1 and so on. In the loop, you can check for intersection by using a code like intersect(A{3,1},A{1,10}) which is actually intersect(B3,C10).
Hope this helps
G.