login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A338987 Number of rooted graceful labelings with n edges. 2

%I #16 Dec 23 2020 19:49:16

%S 1,1,2,6,24,108,596,3674,26068,202470,1753884,16435754,168174596,

%T 1842418704,21757407158,272771715272,3649515044178,51532670206504,

%U 770442883634326,12093451621846094,199856952123506304,3452120352032161404,62471981051497913826,1177664861561125869100,23163177237781937250558

%N Number of rooted graceful labelings with n edges.

%C A graceful labeling of a graph with n edges assigns distinct labels l(v) to the vertices such that 0<=l(v)<=n and the n differences |l(u)-l(v)| between labels of adjacent vertices are distinct. It is rooted if, in addition, either |l(u)-l(w)|>|l(u)-l(v)| for some neighbor of u or |l(v)-l(w)|>|l(u)-l(v)| for some neighbor of v, whenever |l(u)-l(v)|<n.

%C To generate such a labeling, choose one of the k+1 edges 0--(n-k), 1--(n+1-k), ..., k--(n-k), for each k=0, 1, ..., n-1, provided that at least one of the endpoints has already appeared in a previously chosen edge when k>0.

%H David A. Sheppard, <a href="http://dx.doi.org/10.1016/0012-365X(76)90051-0">The factorial representation of major balanced labelled graphs</a>, Discrete Math., Vol. 15, No. 4 (1976), 379-388.

%e a(5) = 108 < 120 = 5!, because 0--5,0--4,0--3,3--5,1--2 and 0--5,1--5,2--5,0--2,1--3 are forbidden, as well as five each beginning with 0--5,0--4,2--5,1--3 and 0--5,1--4,0--3,2--4.

%o (Python)

%o def solve(d, m_in):

%o ....global _n, _cache

%o ....args = (d, m_in)

%o ....if args in _cache:

%o ........return _cache[args]

%o ....if d == 0:

%o ........rv = 1

%o ....else:

%o ........rv = 0

%o ........m_test = 1 | (1<<d)

%o ........for p in range(_n + 1 - d):

%o ............if m_in & m_test:

%o ................rv += solve(d-1, m_in | m_test)

%o ............m_test <<= 1

%o ...._cache[args] = rv

%o ....return rv

%o def a338987(n):

%o ....global _cache, _n

%o ...._cache, _n = {}, n

%o ....return 1 if n<2 else 2*solve(n-2, 3|(1<<n))

%o # _Bert Dobbelaere_, Dec 23 2020

%Y Without rootedness, the number of graceful labelings is n!, A000142, as observed by Sheppard in 1976.

%K nonn

%O 0,3

%A _Don Knuth_, Dec 20 2020

%E a(17)-a(24) from _Bert Dobbelaere_, Dec 23 2020

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 01:35 EDT 2024. Contains 371964 sequences. (Running on oeis4.)