You are on page 1of 5

Heuristics for minimum length geometric

embedding of free trees onto a point set


Parya Noorbakhsh and Alireza Bagheri
Abstract In the geometric graph embedding problem, a graph with n vertices and a set of n points in the plane are given and
the problem deals with finding a mapping between vertices of the graph to these points such that the embedded graph on the
point set has the minimum length. The problem is NP-hard, since the traveling salesman problem is one special case of it. In
this paper, we present some heuristics for embedding a free tree onto a point set on the plane with minimum total edge length.
Index Terms Geometric embedding, Point-set embedding, Computational geometry, Heuristic algorithm



1 INTRODUCTION
He geometric embedding problem has many applica-
tions. Suppose we want to establish a wired comput-
er network with a predefined topology such as star or
tree. If the positions of network terminals are fixed, clear-
ly, we would like to establish this network in such a way
that the required wiring is minimized [3]. This is one ex-
ample of the geometric graph embedding problem in
which we want to map the nodes of a graph to some
points in the plane such that the resulted geometric graph
on the plane has the minimum length. Two other impor-
tant special cases of this problem are the 1-center problem
and the traveling salesman problem (TSP). In the 1-center
problem, the aim is to find a center point among the given
points such that the total length of connecting the points
to the center point is minimized, it is equivalent to the
graph embedding problem when the given graph is a
star. Similarly, if the given graph is a cycle the TSP is
equivalent to this problem. By reduction from TSP, this
problem is NP-complete. Several approximation algo-
rithms are known for TSP: a factor of 2-approximation in
time O(nlogn) using the EMST (Euclidean Minimum
Spanning Tree) [13], a 1.5-approximation in time about
0(n
2.5
log
4
n) [6] using exact Euclidean matching [16], a (2
+ )-approximation in time 0((1)nloglogn) [3] and a
factor of (2 + ) in linear time [4].
Bern et al. [3] considered this problem when the given
graph is a complete tree. They first developed an algo-
rithm that can do geometric sorting approximately in li-
near time. Based on this idea, they devised an 0(logn)-
approximation algorithm in 0(nloglogn) time to embed a
complete tree T with n nodes with maximum degree to a
set of n points in the plane. When all points are on a line,
they presented an exact algorithm using dynamic pro-
gramming in 0(n
5.76
) time and gave a 3-approximation
algorithm in linear time. Bagheri and Razzazi [1] also
gave another approximation algorithm with approxima-
tion factor 0(pb(I)) which runs in linear time to embed
an n-vertices of general free tree T to a set of n points in
the plane, where pb(I) is the minimum depth [2] of a tree
path. The approximation factor provided by them is bet-
ter than the approximation factor of Bern et al. For many
n-node trees, pb(I) is much less than logn.

In this paper, we develop practical algorithms to solve
this problem when the given graph is a free tree. The or-
ganization of the paper is as follows. Some TSP heuristics
that are used during the paper, are given in Section 2. We
present our heuristic approach in Section 3. Experimental
results are shown in Section 4. Finally, we propose a few
suggestions for future work and conclude the paper in
Section 5.

2 TSP TOUR CONSTRUCTION HEURISTICS

In the traveling salesman problem (TSP), which is close-
ly related to the Hamiltonian cycle (HC) problem [6], we
are given a set {c
1
,c
2,
c
n
} of cities and for each pair
{c
i
,c
j
} of distinct cities a distance d (c
i
,c
j
).. Our goal is to
find an ordering of the cities that minimizes quantity:

J(c
n()
, c
n(+1)
) +J(c
n(n)
, c
n(1)
)
n-1
=1


This quantity is referred to as the tour length, since it is
the length of the tour that a salesman would make when
visiting the cities in the order specified by the permuta-
tion, returning to the initial at the end. We shall concen-
trate on the Euclidian TSP, in which the distances satisfy
d (c
i
,c
j
). = d (c
j
, c
i
) for 1 i, j n and the triangle inequali-
ty holds d (c
i
,c
k
) d (c
i
, c
j
) + d (c
j
,c
k
) for all i, j and k
[10,12]. We use some TSP heuristics such as: nearest
neighbor, farthest insertion and tree approximation for
constructing a TSP path and then we will improve the
path by using local search algorithm. In following we de-
scribe how to compute each.

T

Parya Noorbakhsh Department of Electrical , IT & Computer Sciences,
Islamic Azad University, Qazvin, Iran

Alireza Bagheri Department of Computer Engineering & IT, Amirkabir
University of Technology , Tehran, Iran

JOURNAL OF COMPUTING, VOLUME 4, ISSUE 9, SEPTEMBER 2012, ISSN (Online) 2151-9617
https://sites.google.com/site/journalofcomputing
WWW.JOURNALOFCOMPUTING.ORG 36
2012 Journal of Computing Press, NY, USA, ISSN 2151-9617


2.1 The nearest neighbor algorithm
This is perhaps the simplest and most straightforward
TSP heuristic. The key to this algorithm is to always visit
the nearest city. Following steps show the algorithm:

a) Start with any node as the beginning of the path.
b) Find the node closest to the last node added to the
path.
c) Repeat step (b) until all nodes are contained in the
path. Then, join the first and last nodes. The running
time for nearest neighbor as described is O(n
2
)
[10,16].

2.2 The tree algorithm
The algorithm uses minimum spanning tree (MST), the
MST can be computed in polynomial time and consists of
the lower bound for minimum length embedding in a
point set. The algorithm is as follows:

a) Use Prim or Kruskal [6] to construct an MST of the
graph corresponding to an instance of TSP.
b) Duplicate all edges, we can now easily construct an
Euler cycle.
c) Traverse the cycle, but do not visit any node more
than once, taking shortcuts when a node has been
visited.

Let OPT denote the cost of the minimum weight tour. By
contradiction example the length of MST OPT, so when
we duplicate all edges in step (b) to construct an Euler cycle,
this pseudotour, PT has Cost = 2 MST 2 OPT. By
using the triangle inequality in step (c), PT will change to
T*, therefore cost of T* 2 OPT, So this algorithm is
known as a 2-approximate algorithm and it has
O(n
2
logn) complexity [10].

2.3 The farthest insertion algorithm
We have different types of insertion algorithms, Such as
nearest, cheapest and farthest insertions that all of them follow
two structures: First, of all they select the city to be added
which has (minimal, cost-effective, maximal) distance to the
previously chosen city, next insert the selected city among the
cities. Nearest insertion chooses the city x which minimizes d
(I

; x); cheapest insertion chooses the city x which minimizes


Cost (I

; x); farthest insertion chooses the city x which max-


imizes d (I

; x); following steps will show farthest insertion


algorithm.

a) Select the farthest edge and make a subtour of it.
b) Select a city not in the subtour, having the farthest dis-
tance to any one of the cities in the subtour.
c) Find an edge in the subtour such that the cost of inserting
the selected city between the edges cities will be minim-
al.
d) Repeat step (b) until no more cities remain.

Farthest insertion runs in O(n
2
) and no approximation proper-
ties are known for it; nevertheless it is the most effective in
practice, since it constantly produces better solutions than
nearest and cheapest insertions [15].

2.4 Tour improvement
Having chosen a tour, the next step try to improve
this tour as far as possible, we want to apply post-
optimization. This means that we consider sets of solutions
that are neighboring in some sense and look for a local
optimum.

In combinatorial optimization, LinKernighan [8,12]
is one of the best heuristics for solving the Euclidean
traveling salesman problem. It briefly involves swapping
pairs of sub-tours to make a new tour. LinKernighan is
adaptive and at each step decides how many paths (i.e.
links) between cities need to be switched to find a shorter
tour. Perhaps the most important problem concerns
which value of one should choose. In general, the larger
the value of , the more likely it is that the final tour is
optimal, but the complexity will grow correspondingly.
As a result, the values = 2 and = 3 are the most com-
monly used. We restrict ourselves to the simpler case =
2 and examine it.


Figure 1. A 2-Opt move

The 2-opt algorithm systematically looks at each pair
of nonadjacent edges of the current tour and determines
whether the tour length would be decreased by removing
these two edges and adding the other possible pair of
edges which would result in a tour; see Figure1. If so, the
exchange is performed and the search for an improving
pair of edges continues. This will result in a noncrossing
tour for points in the plane. Moreover, a noncrossing tour
will often have its length reduced by this heuristic. Each
iteration of 2-opt algorithm has complexity O(n
2
) [9], but
the number of iterations cannot be predicted.

3 OUR HEURISTIC APPROACH

Our heuristic approach is different from Bagheri and
Razzazi [1], where they converted a tree into a simple
path. Their algorithm has linear time complexity and
approximation factor of O(pb(I)). In our heuristics ap-
proach we embed the given tree directly onto a point set,
by finding the longest path of the free tree [7]. Then we
embed it onto the TSP tour of the point set, preserving
JOURNAL OF COMPUTING, VOLUME 4, ISSUE 9, SEPTEMBER 2012, ISSN (Online) 2151-9617
https://sites.google.com/site/journalofcomputing
WWW.JOURNALOFCOMPUTING.ORG 37
2012 Journal of Computing Press, NY, USA, ISSN 2151-9617


points for subtrees connected to the longest path. Our
heuristic algorithm is as follows:

1. Find the TSP tour of the point set as mentioned in
section 2.
2. Find the longest path of a free tree.
3. For each (s e longest path) do this:
a) First embed s in the TSP
b) Embed all nodes of subtree T
s
in the TSP

In the above algorithm, s means a node of the longest path and
T
s
is the subtree connected to s. In step 3(a), we embed nodes
of the longest path in order they appear in the path onto the
TSP and in step 3(b), we embed the nodes of T
s
as they are
visited by BFS or DFS algorithms. The time complexity of our
heuristic approach is O(n). A sample embedding, appears in
Figure 2 and Figure 3.

(a) (b) (c)
Figure 2. (a) A rooted tree, (b) A point set with TSP path,
(c) The embedding of the tree by BFS algorithm.

As you see in Figure 2(a), the longest path of the tree is
shown by thick solid line and the subtrees connected to
the longest path are shown in rectangles. In Figure 2(b),
first we find the TSP path of the point set and then we
embed the thick line onto this path according to the order
of the thick line. We start from node 16, then for nodes 4,1
and 2 we embed subtrees a, b and c respectively. In Fig-
ure 2(b), points have labeled by BFS algorithm in each
rectangle. Finally Figure 2(c) have shown the embedding
of the tree.
(a) (b) (c)
Figure 3. (a) A rooted tree, (b) A point set with TSP path,
(c) The embedding of the tree by DFS algorithm.







Figure 3 is similar to Figure 2, with the difference that
in Figure 3(b), points have labeled by DFS algorithm in
each rectangle. So the total embedding of the free tree
have changed, see Figure 3(c).

We compare the results of Bagheri and razzazis algo-
rithm [1] with our results. The algorithms run on the well-
known TSP datasets, namely TSPLIB [14]. We use some of
the TSPLIB datasets and run the algorithms 100 times per
each dataset with a different random tree. We divide each
result by the length of MST; obviously the length of MST
is a lower bound for the optimal solution. Table I shows
the ratios of length of embedded tree to the length of MST
for Bagheri and razazzis approach. Tables II and III illu-
strate the ratios for every point set using DFS and BFS
respectively. These values are averages on 100 random
trees for each 8 datasets, see Figures 4 and 5.


4 EXPERIMENTAL RESULTS

The results show that as the number of points increase
the total length of the embedding for each dataset will
increase. Totally, in each case the average result of em-
bedding by DFS is better than the result by BFS, see Fig-
ures 4 and 5. As shown in Figure 4, our heuristic with tree
algorithm is worse than the other heuristics and even the
average results by DFS algorithm for each case is almost
better in compare with bagheri and razzazis approach,
where shows by dashed line (tree algorithm 1) in Figure
4.

TABLE I. Average ration of length of embedded tree
to length of MST







Dataset
name
Bagheri and razazzis approach
Tree Algorithm 1
Tree Algorithm 1
with 2-opt
berlin52 3.922507 3.107107
pr76 4.8114243 4.335874
eil101 4.4101630 3.927404
ch150 5.866791 5.416298
d198 12.093542 8.517549
a280 8.096138 7.497124
lin318 9.448688 9.538094
rd400 9.164398 8.886493
Average 7.226706 6.403243
JOURNAL OF COMPUTING, VOLUME 4, ISSUE 9, SEPTEMBER 2012, ISSN (Online) 2151-9617
https://sites.google.com/site/journalofcomputing
WWW.JOURNALOFCOMPUTING.ORG 38
2012 Journal of Computing Press, NY, USA, ISSN 2151-9617






TABLEII.AveragerationoflengthofembeddedtreebyDFStolengthofMST







TABLEIII.AveragerationoflengthofembeddedtreebyBFStolengthofMST
















Dataset
name
Our heuristics approach
Tree algorithm
2
Tree Algorithm
2 with
2-opt
Nearest
Neighbor
Nearest
Neighbor
with 2-opt
Farthest
Insertion
Farthest Insertion
with 2-opt
berlin52
3.557078 3.380299 3.265219 3.518090 3.830050 3.838838
pr76
4.740707 4.718609 4.656452 4.427880 4.391871 4.348908
eil101
4.032241 3.675578 3.946390 3.728773 3.627617 3.636834
ch150
6.287418 5.975272 6.019344 6.133169 6.101182 6.098791
d198
11.047765 10.751100 9.110381 10.128684 9.337893 9.178652
a280
8.569383 8.444273 8.284632 8.209793 8.841213 8.656417
lin318
9.553417 9.688064 9.367861 10.022092 9.199711 9.218039
rd400
8.346377 7.776789 8.292514 8.004920 7.947497 7.923566
Average 7.016798 6.801248 6.617849 6.771675 6.659629 6.612506
Dataset
name
Our heuristics approach
Tree Algorithm
2
Tree Algorithm
2
with 2-opt
Nearest
Neighbor
Nearest
Neighbor with
2-opt
Farthest
Insertion
Farthest Insertion
with 2-opt
berlin52 3.754026 3.986709 3.503908 4.134290 4.144739 4.166351
pr76 5.474790 5.330508 5.453583 5.448682 5.186072 5.162756
eil101 5.084424 4.805076 5.167158 4.829064 4.709435 4.696009
ch150 7.880447 7.953923 7.648274 8.016167 7.802991 7.801835
d198 14.264864 13.812870 10.893560 12.699644 12.936955 13.782689
a280 10.843688 11.859794 10.869190 10.600052 12.489761 12.253090
lin318 12.400354 12.658817 12.195178 13.074250 12.388543 12.442729
rd400 11.917602 11.942263 12.125445 12.048793 11.552441 11.432098
Average 8.952524 9.043745 8.482037 8.856368 8.901367 8.967195
JOURNAL OF COMPUTING, VOLUME 4, ISSUE 9, SEPTEMBER 2012, ISSN (Online) 2151-9617
https://sites.google.com/site/journalofcomputing
WWW.JOURNALOFCOMPUTING.ORG 39
2012 Journal of Computing Press, NY, USA, ISSN 2151-9617






Figure 4. Results by DFS algorithm and Bagheri and Raz-
zazis approach[1]



Figure 5. Results by BFS algorithm and Bagheri and Raz-
zazis approach[1]

5 CONCLUSION

Geometric embedding of trees is a wellknown NP
complete problem. For solving this problem we pre
sented some heuristics. These heuristics work well for
wide graph (i.e. trees that have long diameter) and then
we compared our results. The quality of our heuristics
areimprovedbyusingDFSandBFSalgorithm.

Forfuturework,itwouldbedesirabletoworkonmeta
heuristics approach or finding a way to improve recent
results.Aninterestingopenproblemistodevelopbetter
approximationfactorforthisproblem.


REFERENCES
[1] A. Bagheri, M. Razzazi, An approximation algorithm for
minimum length geometric embedding of trees, unpub-
lished, 2010.
[2] A. Bagheri, M. Razzazi, Minimum height path partition-
ing of trees, Scientia Iranica, 17, pp. 99-104, 2010.
[3] M. W. Bern, H. J, Karloff, P. Raghavan, B. Schieber, Fast
Geometric Approximation Techniques and Geometric Em-
bedding Problems, Theoretical Computer Science, 106, pp.
265-281, 1992 .
[4] T. M. Chan, Well-seperated pair decomposition in linear
time, Inform. Process.Lett., 107, pp. 138-141, 2008.
[5] N. Christofides, Worst-case analysis of a new heuristic
for the travelling salesman problem, unpublished, 1976.
[6] T. Cormen, C. Leiserson, R. Rivest, Introduction to Algo-
rithms, The MIT Press Cambridge, Massachusetts London,
England, 1990.
[7] F. Harary, Graph Theory, Reading, MA: Addison-
Wesley, 1994.
[8] K. Helsgaun, An Effective Implementation of the Lin-
Kernighan Traveling Salesman Heuristic, Department of
Computer Science, Roskilde University, 1998.
[9] D. Johnson, L. McGeoch, The Traveling Salesman Prob-
lem: A Case Study in Local Optimiz-ation , J. Wiley and
Sons, London, pp. 215-310, 1997 .
[10] D.S. Johnson, L.A. McGeoch, Experimental Analysis of
Heuristics for the STSP, in The Traveling Salesman Problem
and its Variations G. Gutin and A. Punnen, Editors, Kluwer
Academic Publishers, pp. 369-443, 2002.
[11] D. Jungnickel, Graphs, Networks and Algorithms, Third
Ed., Springer-Verlag, 2008.
[12] S. Lin, Computer solutions of the travelling salesman
problem, Bell Systems Technical Journal, 44, pp.22452269,
1965.
[13] F. P. Preparata, M. I. Shamos, Computational Geome-
try: An Introduction, Springer-Verlag, 1985.
[14] G. Reinelt, TSPLIBA traveling salesman problem li-
brary, ORSA Journal on Computing, 3, pp. 376-384, 1991.
[15] D. J. Rosenkrantz, R. E. Stearns, P. M. Lewis, An analy-
sis of several heuristics for the traveling salesman problem,
SIAM J. Comput. , 6, pp. 563-581, 1977.
[16] P. M. Vaidya, Geometry helps in matching, In: Proceed-
ings of the 20th ACM Symposium on Theory of Computing,
pp. 422-425, 1988.


Parya Noorbakhsh recived the M.S. degree in computer engineer-
ing from Islamic Azad University (IAU), Qazvin branch at Qazvin, the
B.S. degree in computer engineering from Sajad University, mashad
Branch at mashad. Her research interests include algorithm
and computational geometry.

Alireza Bagheri recivied the B.S and M.S degrees in computer en-
gineering from sharif University of Technology (SUT) at Tehran, the
Ph.D degree in computer science from Amirkabir University of Tech-
noloy (AUT) at Tehran. Curently he is an assistant professor in the
computer engineering and IT department at Amirkabir University
Tecnology at Tehran.His research interests include computational
geometry, graph drawing and graph algorithms.
JOURNAL OF COMPUTING, VOLUME 4, ISSUE 9, SEPTEMBER 2012, ISSN (Online) 2151-9617
https://sites.google.com/site/journalofcomputing
WWW.JOURNALOFCOMPUTING.ORG 40
2012 Journal of Computing Press, NY, USA, ISSN 2151-9617

You might also like