vv

12453 Reputation

19 Badges

10 years, 1 days

MaplePrimes Activity


These are replies submitted by vv

In Maple 2016.2 (64 bit) I obtain the correct result (for any value of UseHardwareFloats).

OK, but I don't see any collecting rule here. From a Maple point of view this would make sense if you want e.g. to extract some subexpression. But this subexpression must be somehow defined.

@taro 

@tomasmedici 

Yes, Carl found a counterexample for 4x4.
You have 2 options.
1. Use

IsI := proc(G1::GRAPHLN, G2::GRAPHLN, phi::name)
try  GraphTheory:-IsIsomorphic(args); 
  catch: false;  # actually FAIL
end try;
end proc:

It is OK for 4x4 (I have have checked it for graphs without loops).

2. Use the "from scratch" version. It works in all situations but is slower.
Note that for 5x5 there are too many graphs:  > 10^6 without loops and > 3*10^7 including loops, so you cannot list them.

@Carl Love 

Yes, for the proper digraphs (no loops) with 4 vertices I counted 110 counterexamples. It seems that for all of the pairs the graphs are not isomorphic. So, a better workaround for the moment would be:

IsI := proc(G1::GRAPHLN, G2::GRAPHLN, phi::name)
try  GraphTheory:-IsIsomorphic(args); 
  catch: FAIL;
end try;
end proc:

where FAIL should (probably) be interpreted as false.
 

@tomleslie 

1. The "extraneous crap" inverts the isomorphism G2-->G1. This would be necessary when IsIsomorphic(G1,G2,f) gives an error but  G1 and G2 are still isomorphic and f is wanted.
2. I said: seems to work. Anyway it works for the original question.
3. Do you have an example of a workaround for a Maple command which is guaranteed to work in each and every situation? I'd say that IsIso it's a typical workaround; do you have a counterexample for it?


 

 

@tomleslie 

It seems that my workaround is invisible :-)

IsIso(G1,G2);
      false

 

@mehdibaghaee 

It is not easy to construct good examples. This one is not good enough. How do you know that your eigenvalues are correct? (Keep in mind that the determinant is very complicated to compute and would need exact entries which you don't have).
An ideal example would have rational (or even integer) entries and all the eigenvalues be known (not necessarily rational, but relatively simple).
Maple is able to compute Eigenvalues(K,M)  but I simply don't know how far are these eigenvalues from the exact ones for such huge matrices. So, good examples are mandatory.

Note that for standard eigenvalues Maple works very well and probably it is fine for generalized ones too; for your example they are not close but I suspect that your eigenvalues are not correct.

restart;
with(LinearAlgebra):
n:=700:
L:=[seq(3.333*k,k=1..n)]:
A:=DiagonalMatrix(L,datatype=float[8]):
Q:=RandomMatrix(n,n, generator=rand(-1. .. 1.)):
Q1:=Q^(-1):
B:=Q1.A.Q:
LL:=sort(convert(Eigenvalues(B),list)):
max(abs~(L-LL));
#                  HFloat(4.88817022414878e-8)

 

 

Have you tried the above workaround? (Just use IsIso instead of IsIsomorphic). E.g.

restart;
IsIso := proc(G1::GRAPHLN, G2::GRAPHLN, phi::name)
local r;
try  GraphTheory:-IsIsomorphic(args); 
  catch:
  if nargs=2 then GraphTheory:-IsIsomorphic(G2,G1);
  else r:=GraphTheory:-IsIsomorphic(G2,G1,phi);
       phi:=sort(map(u -> rhs(u)=lhs(u), eval(phi)));
  r;
  fi;  
end try;
end proc:
interface(rtablesize=infinity):
n:= 3: N:= n^2:
<ListTools:-Categorize(
   (M1,M2)-> IsIso(GraphTheory:-Digraph~([M1,M2], n)[]),
   map(L-> Matrix(n,n,L), combinat:-permute([0$N, 1$N], N)   )
)>; 

 

@tomasmedici 

This is not possible without examples with known eigenvalues, because the accuracy of the command (working with hardware floats) is not documented for such large matrices. But you refuse to provide them.

@mehdibaghaee 

The workaround above seems to work now in all situations (i.e. including the correct isomorphism if requested).


@dharr 

@tomleslie 

An ad-hoc workaround:

IsIso := proc(G1::GRAPHLN, G2::GRAPHLN, phi::name)
local r;
try  GraphTheory:-IsIsomorphic(args); 
  catch:
  if nargs=2 then GraphTheory:-IsIsomorphic(G2,G1);
  else r:=GraphTheory:-IsIsomorphic(G2,G1,phi);
       phi:=sort(map(u -> rhs(u)=lhs(u), eval(phi)));
  r;
  fi;  
end try;
end proc:

Edit:  seems to work in all situations and returns the correct isomorphism.

@mehdibaghaee 

OK, I wish you good luck.

@mehdibaghaee 
It is your turn to say something about the points 1-2 above. After that I will be able to comment. (How do you know that the method works without examples with known eigenvalues?)

@mehdibaghaee 

The problem is changed now.
You should test the problem with small matrices. Nobody will want to see (and work with) your 700x700 matrices.
Note that Eigenvalues (unlike Determinant) works for big matrices (due to special algorithms) so probably the change of variables is not needed.


 

restart;

with(ListTools):

ti:=time():
s:=0: n:=0:
for i by 1 to 1000 do
        lista:=RandomTools[Generate](list(integer(range = 1 .. 365), 30)):
        if numelems(FindRepetitions(lista)) >= 1 then  s:=s+1 else  n:=n+1  end if;
end do:
time()-ti;
s,n;

0.47e-1

 

697, 303

(1)

# faster

ti:=time():
s:=0: n:=0:
for i by 1 to 1000 do
        lista:=RandomTools[Generate](list(integer(range = 1 .. 365), 30)):
        if nops({lista[]})<30 then  s:=s+1 else  n:=n+1 end if;
end do:
time()-ti;
s,n;

0.15e-1

 

711, 289

(2)

 


 

Download lista1.mw

First 108 109 110 111 112 113 114 Last Page 110 of 166