Development of Cognitive tools for advanced Mathematics learnng based on soft...
tree-gen-algo
1. Arithmetical properties of tree generation codes and algorithm to
generate all tree codes for a given number of edges
K. Balasubramaniana
, N. Chandramowliswaranb
, N. Ramachandranb
,
S. Arunc
, Pawan Kumarc
a
Department of Statistics , Indian Statistical Institute, New Delhi, India.
b
Department of Mathematics, Sri Chandrasekharendra Saraswathi Viswa Maha Vidyalaya,
Kanchipuram-631 561, India.
c
Department of Computer Science & Engineering, Sri Chandrasekharendra Saraswathi Viswa Maha
Vidyalaya, Kanchipuram, Kanchipuram-631 561, India.
Abstract:
Graceful Code is a way to represent graceful graph in terms of sequence of
non-negative integers. Given a graceful graph G on “q” edges, we can generate its
graceful code in the form of (a1, a2, a3, …, aq-1, aq) to represent the graph. Similarly, we
can easily draw the graph from the given graceful code.
In this paper, we present an algorithm to generate all possible tree codes on a
given number of edges (say q=30). Moreover, we also present the arithmetic properties of
tree generating codes and an algorithm to check whether the code of a given graceful
graph represents a tree or not. This algorithm uses prüfer code techniques on graceful
codes to perform tree checking. The prüfer technique of removing the lowest labeled leaf
easily determines the code to be a tree or not.
Keywords: Graceful graphs, Graceful codes, α-valuable codes.
Introduction:
Definition 1:
A Graceful labeling of a simple graph G with “q” edges is an injection “f ” from the
vertices of G to the set {0,1, 2, 3, …, q} such that the induced function g: E→{1, 2, …,q}
g (e) = | f(u) - f(v) | for every edge e ={u, v}, is a bijective function
A graph, which has a graceful labeling, is called a Graceful graph.
This labeling was originally introduced in 1967 by Rosa who has also showed that the
existence of a graceful labeling of a given graph G with “q” edges is a sufficient
condition for the existence of a cyclic decomposition of a complete graph of order
“2q+1” into sub-graphs isomorphic to G. [See Ref]. The famous Graceful Tree
Conjecture says that all trees have a graceful labeling.
2. Code of a Graceful Graph:
Let G be any graceful graph on “q” edges then (a1, a2, a3, … , aq-1, aq) is called a graceful
code of G, if 0 ≤ ai ≤ q-i, 1 ≤ i ≤ q. Here ai is the lower end vertex of the edge label “i”.
It is important to note that aq is always zero.
Example:
Code= (4, 3, 1, 2, 1, 0)
Figure 1 shows a graceful graph on 6 edges.
The code of this graceful graph is = (4, 3, 1, 2, 1, 0), where
a1= 4= lower end vertex of the edge label “1”.
a2= 3= lower end vertex of the edge label “2”.
a3= 1= lower end vertex of the edge label “3”.
a4= 2= lower end vertex of the edge label “4”.
a5= 1= lower end vertex of the edge label “5”.
a6= 0= lower end vertex of the edge label “6”.
For every graceful graph G we can write its corresponding graceful code. Conversely, for
every given graceful code we can draw the corresponding graceful graph as follows.
Join edges: {(a1, 1+a1), (a2, 2+a2), …, (aq-1, q-1+aq-1), (aq, q+aq)}
Definition 2:
α-valuable Code:
Let G be a graceful graph on “q” edges. Then the code (a1, a2, a3,…, aq) is called
α-valuable code of G if
a1 ≥ ai ; for all i
Max {ai | 0 ≤ i ≤ q} < Min {i + ai | 0 ≤ i ≤ q}
Here a1 is called the separator or critical value of the α-valuable code.
3. Proposition 1
(a1, a2, a3, …, aq) represents an α-valuable code if and only if
0 ≤ (a1 – aq - i + 1 / q – i) ≤ 1
for all i, 1 ≤ i ≤ q-1
Equivalently, (a1, a2, a3, ..., aq-1, aq) represents an α-valuable code if and only if
(a1 – aq, a1 – aq-1, …, a1 – a3, a1 – a2, 0) represents a code of a graceful graph.
Proposition 2
Define G(q)= { ( a1, a2, …, aq) |0 ≤ ai ≤ q-i }
Let X, Y є G(q), such that,
X= (a1, a2, a3, …, aq-1, aq)
Y= (b1, b2, b3, …, bq-1, bq)
Define X+Y= ( a1+b1 (mod q), a2+b2 (mod q-1), …, aq-1+ bq-1(mod 2), 0 )
Then < G (q), + > = zq + zq-1 + … + z2 + <0>
This sum is a direct sum of cyclic groups of orders q, q-1, …, 2, 1 respectively.
Arithmetic properties of Tree Generation codes
Theorem 1:
Let X= (a1, a2, …, aq) be a given α-valuable tree code on “q” edges.
Let p ≤ q - a1. Then,
(σ( a1+1), σ(a1+2), …, σ(a1+p), X) always represent a tree code on “q+p” edges for any
σ Є Sp= Symmetric group on “p” symbols.
Corollary 1:
Consider the following caterpillar,
N+1
(N
α
1
, (N-1)
α
2, …, 1
α
N, 0
α
N+1). Let “p” be any +ve integer ≤ (∑αi) – N.
i=1
Then (σ (N+1), σ (N+2), …, σ (N+p), N
α
1
, (N-1)
α
2, …, 1
α
N, 0
α
N+1) always represent a
N+1
tree code on “ (∑αi) + p ” edges for any σ Є Sp= Symmetric group on “p” symbols.
i=1
4. Corollary 2:
(σ (1), σ (2), …, σ (q), 0
q
) always represent a tree code on “2q” edges for
any σ Є Sp= Symmetric group on “p” symbols.
Corollary 3
For any positive integer "q",
(2q, 2q-1, …, q+1, q + σ( q), q-1 + σ(q-1), …, 2 + σ(2), 1 + σ(1), σ(1), σ(2), …, σ(q), 0q
)
always represent a α-valuable tree code on “4q” edges
Theorem 2:
Let X= (a1, a2, …, aq) be a given α-valuable tree code on “q” edges, such
that q - a1= odd integer. Then for any m ≥ 2,
((a1+1, a1+2, …, q)m
, X) always represent a tree code on “m(q-a1)+ q” edges.
Corollary 1:
For any odd +ve integer q and m ≥ 2, ((q+1, q+2, …, 2q)m
, qq+1
, q-1,q-2, …,2,1, 0q
)
represent a tree code on “(m+3)q” edges.
Theorem 3:
Suppose X= (a1, a2, …, aq) be a given α-valuable tree code on “q” edges.
Assume q-a1= even integer. Then for any +ve integer m ≥ 2,
((a1+1, a1+2, …, q, a1)m-1
, a1+1, a1+2, …, q-1, q, X) represent a tree code on
“(m+1)q- a1m + m-1” edges.
Theorem 4:
Suppose X= (a1, a2, …, aq) be a given α-valuable tree code on “q” edges
such that
i. q is odd.
ii. a1 is even.
Then,
(1+a1, σ (a1+3), 1+a1, σ (a1+5), 1+a1, …, 1+a1, σ (q), 1+a1, X) represent a tree code on
“2q - a1” edges.
Here σ is any permutation on “(q-a1-1)/ 2” symbols= {a1+3, a1+5, …, q}.
Here 1+a1 is repeated “(q-a1+1)/2” times.
5. Theorem 5:
Suppose X= (a1, a2, …, aq) be a given α-valuable tree code on “q” edges.
Assume,
1) 3│q and 3│a1.
2) a1 ≤ 2.q/ 3.
3) q ≥ 6. Then,
(a1+q-2, a1+q-5, …, 4+a1, 1+a1, a1+q-3, a1+q-4 a1+q-6, a1+q-7,…, a1+3, a1+2, X)
always represent a tree code on “2q-2” edges.
Theorem 6:
Suppose X= (a1, a2, …, aq) be a given α-valuable tree code on “q” edges,
such that,
1) q= even.
2) a1= even.
3) a1 ≤ q/ 2 and q ≥ 4. Then,
(a1+q-1, a1+q-3, …, 3+a1, 1+a1, a1+q-2, a1+q-4, …, a1+4, a1+2, X) always represent a
tree code on “2q-1” edges.
Theorem 7:
(1
n
, n+2, …, n+r+1, 1
n
, 0
2n+r
) represent a tree code on “4n+2r” edges
for any +ve integer n, r.
Theorem 8:
(1, 3, 4, …, n+2, 1, 0
n+2
) always represent a tree code on “2n+4” edges.
(1, σ (3), σ (4), …, σ (n+2), 1, 0
n+2
) always represent a tree code on “2n+4” edges for
any σ Є Sn= Symmetric group on n symbols.
Theorem 9:
9.1. (1, 2, …, 2n, 2n+1, 1, 2, …, 2n, 0
4n+1
) represent a tree code on “8n+2”
edges for any n ≥ 1.
9.2. (1, 3, 1, 5, 1, 7, 1, …, 1, 2q+1, 1, 0
2q+1
) represent a tree code on “4q+2”
edges.
9.3. (1, σ (3), 1, …, 1, σ (2q+1), 1, 0
2q+1
) represent a tree code on “4q+2” edges
for any σ Є Sq = group of permutations on q= {3, 5, …, 2q+1} symbols.
6. Theorem
N+1
10:
Suppose (∑αi) – N = odd +ve integer, then for any +ve integer
i=1
m
N+1 N+1
≥ 2,
((N+1, N+2, …, (∑αi) – 1, ∑αi )
m
, N
α
1
, (N-1)
α
2, …, 1
α
N, 0
α
N+1) always
i=1 i=1
N+1 N+1
represent a tree code on “m[(∑αi) – N ] + ∑αi ” edges.
i=1 i=1
Theorem 11: N+1
Suppose (∑αi) – N = even +ve integer, then for any +ve integer
i=1
m ≥ 2,
N+1 N+1 N+1 N+1
((N+1, N+2, …, (∑αi) – 1, ∑αi , N)m-1
,N+1, N+2, …, (∑αi) – 1, ∑αi,
i=1 i=1 i=1 i=1
N
α
1
, (N-1)
α
2, …, 1
α
N, 0
α
N+1)
N+1
represent a tree code on “(m+1) (∑αi) – Nm+m-1” edges.
i=1
Theorem - 12
Suppose (a1, a2, …, aq-1, aq) represent a code of a graceful tree on “q” edges. Then
X = (aq+q, aq-1+q-1, …, 2+a2, 1+a1, x, a1, a2, a3……, aq-1, aq), [0≤x≤q] represent a
α–valuable tree code on “2q + 1” edges.
Define U(X)
= ( q + 1 + (aq , aq -1 , …, a2, a1) , x + q + 1 , q + 1 + (a1 + 1 , a2 + 2, …, aq + q ) )
U(X)R
q= ( q + 1 + (aq + q, aq-1 + q – 1, …, a2 + 2 , a1 + 1) , x + q+ 1,
q + 1 + (a1, a2, …, aq-1, aq ) ) )
Then
(U(X)R
+ (k – 2)q , q U(X)R
+ (k – 3)q , …, U(X)R
+ q , U(X)R
, X ) always
represent a α–valuable tree code on “2kq + k” edges (k ≥ 3) +== +
==========---ppp0000000iiiii ===[[[[
7. Theorem - 13
Let X1 = (q, a2
(1)
, a3
(1)
, …, a2q
(1)
, a2q+1
(1)
)
X2 = (q, a2
(2)
, a3
(2)
, …, a2q
(2)
, a2q+1
(2)
)
… = …………………………………...
Xi = (q, a2
(i)
, a3
(i)
, …, a2q
(i)
, a2q+1
(i)
)
… = …………………………………..
Xk = (q, a2
(k)
, a3
(k)
, …, a2q
(k)
, a2q+1
(k)
)
Represent “k” α–valuable tree codes on “2q+1” edges of trees T1 , T2, …, Ti, …, Tk
respectively ( k ≥ 3)
Define U(Xi) = ( q + 1, 2 + a2
(i)
, 3 + a3
(i)
, …, 2q + a2q
(i)
, 2q + 1 + a2q+1
(i)
)
U(Xi)R
= ( 2q + 1 + a2q+1
(i)
, 2q + a2q
(i)
, …, 3 + a3
(i)
, 2 + a2
(i)
, q + 1 )
For 1 ≤ i ≤ k
Then
( U(X1)R
+ (k – 2 )q , U(X2)R
+ (k – 3)q , …, U(Xk-2)R
+ q , U(Xk-1)R
, Xk )
represent α–valuable tree code of a tree “T” on “2kq + k” edges such that
E(T) = E(T1) U E(T2) U … U E(Tk)
Also
( U(X1)R
+ (k – 2 )q , U(X2)R
+ (k – 3)q , …, U(Xk-2)R
+ q , U(Xk-1)R
, 0, Xk )
represent a α–valuable tree code of a tree “S” on “2kq + k+ 1” edges.
Theorem - 14
Suppose (a1, a2, …, aq-1, aq) represent a α-valuable tree code of a graceful tree on
“q” edges. Then X = (aq+q, aq-1+q-1,…,2+a2, 1+a1, a1, a2, a3……, aq-1, aq),
represent a α–valuable tree code on “2q” edges.
Define Y = ( 2q – 1 , 2q – 2 , …, q + 1 , q, q – 1 , q – 2, …, 1, 0 ) – X
= ( q – 1 , q – 1 – aq-1 , …, q – 1 – a2, q – 1 – a1 , q – 1 – a1 , q – 2 – a2 ,
…, 1 – aq-1, 0 )
U(Y) = ( q, q + 1 - aq-1, …, 2q – 2 – a2, 2q – 1 – a1 , 2q – a1, 2q – a2, …,
2q – aq-1, 2q )
U(Y)R
= ( 2q, 2q – aq-1 , …, 2q – a2, 2q – a1, 2q – 1 – a1 , 2q – 2 – a2 , …,
q + 1 – aq-1 , q )
Then (U(Y)R
+ (k – 2)q , q U(Y)R
+ (k – 3)q , …, U(Y)R
+ q , U(Y)R
, Y ) always
represent a α–valuable tree code on “2kq ” edges (k ≥ 3) .+=
=
8. Algorithm (Tree Check):
1. q← no. of edges in the graph.
2. q1← q
3. for i← 0 to q-1
4. // Get the code of graph
// Store it in a[0…. q-1]
5. for i← 0 to q-1
6. if (a[i] < 0 or a[i]> q-i-1)
7. // not a graceful code
8. exit
9. for i←1 to q
10. do b[i-1] = i+a [i-1]
11. // upper code stored in array b[]
12. for key←0 to q1
13. element ← 0
14. j← 0
15. while (j<q)
16. if (key= a[j] or key= b[j])
17. element← element +1
18. j← j+1
19. else
20. j← j+1
21. if (element=0)
22. code does not represent tree
23. exit
24. key← 0
26. while (key <=q1)
27. element← 0
28. j← 0
29. while (j<q)
30. if (key=a[j] or key=b[j])
31. element← element +1
32. j← j+1
33. else
34. j← j+1
35. key← key+1
36. if (element=1)
37. SEARCH (key-1)
38. if (z<2*q1)
39. code does not represent tree
9. SEARCH (temp):
1. for n←0 to q-1
2. if (a[n]= temp or b[n]= temp)
3. TREEVERT (n)
4. VERDELETE (n, q)
5. key← 0
TREEVERT (d)
1. tree [z]←a[d]
2. z← z+1
3. tree [z]←b[d]
4. z← z+1
5. if (z=2*q1)
6. // code represents a tree
VERDELETE (n, k)
1. for x← n to k-2
2. a[x]← a[x+1]
3. b[x]← b[x+1]
4. k← k-1
5. q← k
10. Reference:
1. T. H. Cormen, C. E. Leiserson, R. L. Rivest, C. Stein, Introduction to
Algorithms, MIT Press, Cambridge, 2001.
2. Pawan Kumar, Graceful Graph: Code Operator, Software Project Thesis, Dept.
of Computer Science& Engineering, SCSVMV, Kanchipuram, India,2005.
3. A. Rosa, “On certain valuations of the vertices of a graph”,Theory of Graphs,
Proc. Sympos. Rome, 1996, Dunod, Paris, 1967, pp.349-355.
4. A. Rosa, Labeling snakes, Ars Combinatoria 3 (1977), 67-74.
5. C. Huang, A. Kotzig, and A. Rosa “Further results on Tree Labelings”, Utilitas
Mathematica, Vol. 21C (1982), pp 31-48.