Do you wish to construct the outputs, or just need their sizes?

Assuming the former,  I managed to make the thing more complicated by either
calling a function to add a column to a combination matrix,  or embedding
its code in the graphs routine.  This saves repeating in (n+1)comb m what
you've already done in n comb m,  but the time improvement is marginal if
anything,  and my versions use slightly more space!  So I won't bore you
with the details.

There appear to be rather complicated algorithms for deriving their sizes,
eg Wang at https://arxiv.org/pdf/1604.04148.pdf

Best of luck!
Mike

On 19/06/2020 19:59, Raul Miller wrote:
https://oeis.org/A004251

require'stats'

graphs=:verb define
   r=. ,a:
   if. 1 < y do.
     m=. #pairs=. 2 comb y
     for_n.1+i.m do.
       raw=. pairs{~ n comb m
       ndx=. (i. ~.) \:~@(#/.~)@,"2 raw
       r=. r, ndx <@{ raw
     end.
   end.
)

    #@graphs"0 i.8
1 1 2 4 11 31 102 342

This implementation is too inefficient, in my opinion, to go further than that.

Does anyone here have a more efficient implementation?

Thanks,


--
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to