Journal of Graph Algorithms and Applications Embedding Vertices at Points:

advertisement

Journal of Graph Algorithms and Applications

http://www.cs.brown.edu/publications/jgaa/

vol. 6, no. 1, pp. 115–129 (2002)

Embedding Vertices at Points:

Few Bends suffice for Planar Graphs

Michael Kaufmann Roland Wiese

mk@informatik.uni-tuebingen.de

wiese@informatik.uni-tuebingen.de

Abstract

The existing literature gives efficient algorithms for mapping trees or less restrictively outerplanar graphs on a given set of points in a plane, so that the edges are drawn planar and as straight lines.

We relax the latter requirement and allow very few bends on each edge while considering general plane graphs. Our results show two algorithms for mapping four-connected plane graphs with at most one bend per edge and for mapping general plane graphs with at most two bends per edge. Furthermore we give a point set, where for arbitrary plane graphs it is NP-complete to decide whether there is an mapping such that each edge has at most one bend.

Communicated by H. de Fraysseix and and J. Kratochv´ıl: submitted February 2000; revised May 2001.

M. Kaufmann and R. Wiese, Few Bends ,

JGAA

, 6(1) 115–129 (2002) 116

1 Introduction

The problem of mapping the vertices of a graph to points in the plane has been considered in the past under various objectives depending on the specific applications. This ranges from the band width minimization problem [17, 8] where the points are at unit distance on a line and the objective is to minimize the distance of the points between adjacent vertices to embedding problem of a guest graph onto a host graph [14] under some objectives like dilation, congestion, load, etc.

Here we consider a more geometric version of the problem: Originally, the problem was how to map a given tree T of n vertices at a given set of points

S in the plane such that the edges can be drawn straightline and without any crossings. Variants of this problem have been explored, either with or without keeping the position of one specific node fixed [16, 12, 2].

Generalizing the graph class, but still using the required straightline planar drawing, Gritzmann et al. [11] gave an elegant divide and conquer scheme to partition the point set and the set of vertices simultaneously. They showed that using this mapping outerplanar graphs can be drawn without any bends.

In the consequent papers [3] and [1], efficient implementations have been developed. The latest result in [1] is an O ( n

· log

3 n ) time algorithm to find a straightline drawing for such a graph. Astonishingly enough, the case for more general planar graphs has not been considered systematically. It is at exactly this point that we start.

Another similar scenario has been recently considered by Pach and Wenger

[15]. They assume that the mapping of the vertices to the points is already fixed. The authors prove that O ( n ) bends per edge are sufficient and that we can not expect to significantly improve the worst case bound for the maximum number of bends per edge.

We consider just the first scenario where the mapping of the vertices to the points is not yet fixed. On the other hand, we preserve the given planar embedding of the graph. In the next section, a simple scheme is presented, that provides drawings with at most one bend per edge for a large class of graphs. Next we generalize the technique so that it will work for any planar graph and produces drawings with at most two bends per edge. In section

4, we give a class of graphs and a set of points, where we can prove that there is at least one edge with two bends. Finally, we extend the techniques

M. Kaufmann and R. Wiese, Few Bends ,

JGAA

, 6(1) 115–129 (2002) 117 developed so far to a simple proof to the expected NP-completeness result, namely to decide whether a drawing can be found where each edge has at most one bend.

Throughout this paper, we deal with triangulated embedded (plane) graphs, only in the last section do we discuss a more general case. Of course, we always require the drawings to be planar, even if it is not explicitly stated.

2 A basic technique

In this section, we present the basic technique for the mapping and consider the following restriction on the graph.

Let G = ( V, E ) be any plane graph with a hamiltonian cycle C , such that

C has at least one edge, say e , on the outer face of G . We call such a property

’external hamiltonicity’ and a corresponding cycle ’external hamiltonian’. We assume the vertices of V to be ordered from v

1 to v n as being prescribed by the hamiltonian cycle C . The vertex with the smallest index is chosen such that the edge e is incident to v n and v

1

.

Let S be any set of points p 1 , p 2 , ..., p n with p i

= ( x i

, y i

). Assume the plane is rotated in such a way to make the x -coordinates of the points pairwise different. Furthermore assume that the points are ordered with increasing x -coordinates. Now we map the hamiltonian cycle C = ( v 1 , v 2 , . . . , v n

, v 1 ) to the points p

1

, ..., p n

, so that the edge e = ( v n

, v

1

), is assigned in such a way that v n

= p n and v

1

= p

1

. All edges on C with the exception of e can be drawn as a straight line so that they extend monotonically in x -direction.

The edge e is drawn from the rightmost point p n to the leftmost point p

1 with one bend b located at a place existing very high above all the other points.

The idea is to choose the segments of e such that their slopes are the same and they are cone-shaped, c.f. figure 1. The slopes of e is determined by the maximal slope of the straightline edges on the hamiltonian path C

− e . This also determines the place where the bend of e is located.

by

More precisely, the slope for a possible straightline segment is computed

σ

0

= max i

| y i

+1

− y i

|

/ ( x i

+1

− x i

). To ensure that the segments of e do not interfere with other segments or points, we have to increase the value σ slightly. In fact, we assign the value σ = 2

·

σ

0 as the slope of a line through

0

M. Kaufmann and R. Wiese, Few Bends ,

JGAA

, 6(1) 115–129 (2002) 118 p

1 and

σ should be the slope of another line through of the two lines gives the position of bend b .

p n

. The intersection

The remaining edges are drawn each with exactly one bend such that all the left segments of the edges have the same slope σ and the right segments will have the slope

σ . They will run in parallel. This is more because of aesthetic reasons and to simplify the arguments about avoiding some possible crossings. The edges inside of C are drawn above the polygonal chain C

− e , and the edges outside are drawn below. The following case checking proves the planarity of the drawing:

Edges inside and outside of C do not cross since they are separated by the polygonal path C

− e . We explain the case of two edges e of C in more detail. Let e

1

= ( v i

, v l

) and e

2

= ( v j

, v k

1 and e

2 inside

). Clearly i

≤ j < k

≤ l holds because of planarity. Now, since the left segments run in parallel and the right segments as well and the four end points occur in that order on the x -monotone polygonal line C

− e , there are no crossing segments.

The same holds for the edges outside. The slopes for the segments of the edges not in C have been chosen large enough such that edges in C cannot interfere with edges not in C .

Note that by this technique, some of the segments adjacent to the same vertex might overlap (cf. the second segments of ( p

2

, p

8

) and ( p 3 , p 8) in Fig.

1). We devise a perturbation scheme that resolves those overlappings:

Let be the minimum distance between any two non-overlapping parallel segments, let L be the maximum length of a segment and maxdeg the maximum degree. For each vertex v , we sort the pairwise overlapping adjacent segments according to their length in decreasing order. For each segment s being the i -th overlapping segment adjacent to v , we rotate s by i

·

L

· maxdeg downwards. The new intersection points for the segments give new positions for the bends. This way we ensure that the previously overlapping segments are spread out, and new intersections are avoided since the rotation angles are kept small enough.

Theorem 2.1

Let S be an arbitrary set of n points and G be any plane graph with an external hamiltonian cycle and n vertices. Then G can be drawn planar with a mapping of the vertices to the points such that each edge has at most one bend.

M. Kaufmann and R. Wiese, Few Bends ,

JGAA

, 6(1) 115–129 (2002) 119

5

6

1

7

4

3

8

2

9 p 1 p 2 p 3 p 4 p 5 p 6 p 7 p 8 p 9

Figure 1: The basic construction

Remarks on the area . Note that the area may be much larger than the area R occupied by the point set. More precisely, let us assume that the minimal enclosing rectangle R is a square of width W and δ is the minimal distance in x -direction between any two points. Clearly, the absolute value of the slope σ of the segments of edge ( v n

, v

1

) is at most 2

·

W/δ . Hence the resulting height is at most 2

·

W

·

W/δ while the width remains the same.

This means that if we assume integer-coordinates ( δ = 1), we achieve an area of O ( W

3

) for the drawing.

Note that if we would allow 2 bends per edge, we could easily draw the edges in an orthogonal way and keep the area proportional to the area of the convex hull of the point set. In this case, the perturbation scheme does not work anymore and we might have to enlarge the size of the vertices and assign offsets to the adjacent segments. The details are left to the reader.

M. Kaufmann and R. Wiese, Few Bends ,

JGAA

, 6(1) 115–129 (2002) 120

δ

Figure 2: Wasting and saving some area by spending another bend per edge.

3 The general case

In order to apply the technique above we need to find an external hamiltonian cycle, namely a hamiltonian cycle including an edge on the outer face.

Testing all possible edges e = ( v, w ) on the outer face, we could request a hamiltonian path, which is a well-known NP-complete problem even on planar triangulated graphs [6]. On the other hand, we know of a linear-time algorithm to find external hamiltonian cycles by Chiba and Nishizeki [5], if the graph is four-connected. Since the graphs we consider are triangulated, the problematic cases appear if there are separating triangles, namely cycles of length 3 which do not circumscribe single faces. Only such graphs may not contain external hamiltonian cycles.

First of all, we give a reduction to the four-connected case which will finally lead to drawings with at most two bends per edge. Then, in the following section we present a small plane graph with only 12 vertices without any external hamiltonian cycle and a point set, and we prove that any planar drawing of this graph on this point set must have at least one edge with 2 bends. This indicates that our simple technique is reasonably good and it will not normally be beaten by other algorithms with respect to the maximal number of bends per edge.

Assume G is a plane triangulated graph which is not four-connected.

Let e = ( v, w ) be an edge of any particular separating triangle which clearly

M. Kaufmann and R. Wiese, Few Bends ,

JGAA

, 6(1) 115–129 (2002) 121 exists. Edge e lies adjacent to two triangular faces ( v, w, s ) and ( v, w, t ).

We destroy those triangles by inserting a dummy vertex z on e , deleting e and connecting z by four new edges to the vertices v, w, s and t . Note that by each single operation, the number of separating triangles decreases and no such triangles are created anew. The dummy vertices z do not appear in any separating triangle. We perform this operation until all separating triangles are destroyed. The separating triangles can be efficiently found by the algorithm of Chiba and Nishizeki [4]. Then the new graph G

0 is fourconnected and triangulated.

We now apply the basic technique described in the previous section to

G

0

. The only modification is the handling of the dummy vertices z . Figure

3 gives an example.

1

2

3 5

10

8

9

4

7 z 1 z 2

11

6

1 2 3 4 5 6 7 z

1 8 9 10 z

2 11 12

12

1 2 3 4 5 6 7 z

1 8 9 10 z

2 11 12

Figure 3: An example for the construction of graphs without external hamiltonian cycle. Vertices z

1 and z

2 are dummies. They arise when destroying the separating triangles. The figures to the right indicate the solutions with three and two bends respectively.

Let C

0 be the external hamiltonian cycle as found by the algorithm of

Chiba and Nishizeki. Clearly, C

0 visits z , and immediately before and afterwards, it visits two vertices a, b

∈ { v, w, s, t

}

. We place a new dummy point p z exactly between the points assigned to a and b .

Then the graph can be drawn as described above. Finally, we remove the edges ( s, z ) and ( t, z ) and join the (at most) two segments of ( v, z ) and

M. Kaufmann and R. Wiese, Few Bends ,

JGAA

, 6(1) 115–129 (2002) 122

( z, w ). This immediately gives a drawing with at most 3 bends per edge, since there is at most one dummy vertex on each edge.

Lemma 3.1

Given an arbitrary plane graph with n vertices and a set of n points in the plane. In time O ( n log n ) , we can find a mapping of the vertices to the points, so that the edges can be drawn planar and with at most 3 bends each.

Markus Eiglsperger suggested a way of saving one bend (out of three) by drawing some of the segments of the edges vertically. In the third part of

Figure 3, we indicate the idea.

Lemma 3.2

Given a solution with at most three bends for each edge constructed by the algorithms above, we can modify the drawing so that it remains planar and the maximal number of bends is two. The used area might grow exponentially.

Proof: Let P be the designated hamiltonian path along the points p

1

, . . . p n such that the edges ( p i

, p i

+1

) are drawn as a straight line.

P induces a partition of the drawing plane into an upper and a lower part. Note that for each edge e with two or three bends there is a dummy vertex d e placed on an edge ( p i

, p i

+1

) where the edge e crosses path P . Following the construction above, it is clear that each edge crosses P once at most, hence the two segments of e incident to the dummy vertex d e may be able to be drawn vertically. We discuss now the implications of such operations:

We consider just the section in the upper part of the drawing, the lower part is handled analogously. Let e be the edge under consideration with segments s

1 and s

2 where s

2 ends at dummy vertex d e

. Let α

1 and angles indicating the slopes of the segments as shown in figure 4.

α

2 be the

90 o

Stretching s

1 such that α

1 remains the same, the angle α and the segment s 2 becomes vertical. We will call it s

0

2

2 increases to now. Planarity is eventually violated if there are some segments s with angle β crossing the cone between s

2 and s

0

2

. We can correct this easily by rotating the segment s such that β also increases. This process is iterated if necessary. Obviously it ends after at most m steps since we only proceed from left to right and never backtrack. The proper nesting of the edges (halfedges) in the upper

M. Kaufmann and R. Wiese, Few Bends ,

JGAA

, 6(1) 115–129 (2002) 123 s 1

α 1 s s

0

2 s 2

β

α 2 d e

Figure 4: The configuration before and after rotating segment s 2 in vertical position.

part of the drawing ensures that for each edge only m rotations are necessary, implying a quadratic running time.

Combined with a corresponding process for the lower part we end when the segments incident to any dummy vertices are vertical and the corresponding bend is saved.

In the second part of the proof we sketch a situation where the area grows exponentially. The next figure shows two nested edges with corresponding dummy vertices on different sides (left and right).

We assume that the slopes are at 45 o to start with and the points and bends lie on integer coordinates. When we perform the modifications described above, so that the segments incident to the dummy vertices become vertical, the drawing grows by more than a factor of two.

Now assume that we have n/ 2 of such pairs nested, as indicated in the next figure. Consider the i -th pair from the inside. The drawing of G i

− 1 includes an axis-parallel rectangle R i determined by the length of the vertical segments of the edges from the i

1-th pair. Next, we see that the two edges from pair i have to circle around this rectangle using only two bends and one vertical segment in the middle. It follows quite easily that the lengths of these segments must be quite large compared to the height of the rectangle

R i

− 1 and that a new rectangle of R i

− 1

R i of height at least twice as large as the height results. Hence, we can conclude that the height of the drawing grows

M. Kaufmann and R. Wiese, Few Bends ,

JGAA

, 6(1) 115–129 (2002) 124 exponentially, at the very least.

e l e r

G i − 1 i-th pair

Figure 5: The recursive definition of the graph with exponential height.

We conclude with a note regarding the runtime. Clearly the first part of the construction works in linear time, since we can use the linear time algorithm of Chiba/Nishizeki [4] to determine the separating triangles. Then the saving of the third bends by rotating some of the segments might cause a quadratic number of steps.

Theorem 3.3

Any plane graph can be mapped on any given point set in the plane and can be drawn with at most three bends per edge in linear time and with at most two bends per edge in quadratic time.

4 The lower bound

Next, we show that this bound is optimal in the worst case. Consider the following triangulated graph discussed in the example from figure 3.

Although there is a hamiltonian path in G , there is no external hamiltonian path. We try to map G on a set of 12 points with the same y -coordinate

Y . This point set has the property that each edge with only one bend must lie completely above or completely below the Y -line. Any edge segment that crosses the Y -line must belong to an at-least-two bend edge.

Let x

1

, . . . , x

12 be the x -coordinates of the points in increasing order.

Since the outer face of G is a triangle with vertices a, b, c it is clear that in any one bend drawing

{ x

1

, x

12

} ⊂ { x a

, x b

, x c

}

(With x a

, we mean the x coordinate vertex a is mapped to). We examine the case where x

1

= x c

, x

12

=

M. Kaufmann and R. Wiese, Few Bends ,

JGAA

, 6(1) 115–129 (2002) 125 a e f h g d b c

Figure 6: The candidate for the lower bound proof.

c d b h g f e a

Figure 7: Edge ( b, f ) needs two bends in this drawing.

x a

. Both of the other cases are similar or symmetric. Next we want to draw the outer face. For that we map b to x b

, ( x

1

< x b

< x

12

) and draw the outer face edges such that ( a, c ) bends above the Y -line and ( a, b ) , ( b, c ) bend below.

Next we draw the edges of the triangles b, d, a and b, c, d . W.l.o.g., we map vertex d to x d

, ( x a

< x d

< x b

) and draw ( a, d ) , ( d, c ) with a bend above the

Y -line. We draw the edge ( d, b ) with a bend above the Y -line and show that one edge within triangle

{ b, d, a

} cannot be drawn with only one bend (since

{ b, c, d

} and

{ b, d, a

} are symmetric, we could show the same for

{ b, c, d

} if we would draw edge ( d, b ) with no bend or a bend below the Y -line).

Now we want to draw the edges from d to e, f and h . Since we do not

M. Kaufmann and R. Wiese, Few Bends ,

JGAA

, 6(1) 115–129 (2002) 126 want to change the embedding and edge ( d, b ) bends above the Y -line, these edges must also bend above the Y -line and the x -coordinates of their end points must obey the order x b

< x h

< x f

< x e

< x c

. Next we draw the edges from a to e, f and g . Since ( d, e ) bends above the Y -line the edges ( a, f ) and

( a, g ) must bend below the Y -line. The order of the coordinates is nearly fixed by now: x d

< x b

< x g

, x h

< x f

< x e

< x a

. Now we are at a point where we cannot draw edge ( b, f ) without letting it cross the Y -line, since

( d, h ) and ( a, g ) have their bends in opposite directions. See Figure 7.

Theorem 4.1

There is a plane triangulated graph with only 12 vertices such that for every placement of the vertices on a straight line at least one edge must bend at least twice in the resulting drawing.

5 The NP-completeness result

In this section we prove

Theorem 5.1

Given any plane graph G with n vertices and n points on a line. The mapping problem of the vertices at the points so that the edges are drawn planar and with at most one bend each is NP-complete.

Proof: To show that the 1-bend drawability problem is NP-complete, we reduce it to the hamiltonian cycle problem for plane graphs.

First, note that the external-hamiltonian-cycle problem for plane graphs is NP-complete since it can be used to solve the hamiltonian-cycle problem for plane graphs by an iteration over all faces of the embedding.

We call a plane graph G = ( V, E ) (external) hamiltonian-extensible if some edges E

0 can be inserted without destroying the previous planar embedding enabling G

0

= ( V, E

E

0

) to become (external) hamiltonian. The problem as to whether a given planar graph G can be made (external) hamiltonian by inserting at most k

0 edges is clearly NP-complete since its variant with k = 0 is equivalent to the (external) hamiltonian-cycle problem for planar graphs.

Let G = ( V, E ) be a given plane graph. The following argument shows that solutions for the problem to make G (external) hamiltonian-extensible

M. Kaufmann and R. Wiese, Few Bends ,

JGAA

, 6(1) 115–129 (2002) 127 can be converted in polynomial time into a 1-bend drawing for G with a set of points on a straight line and vice versa.

If G is external-hamiltonian extensible, we take the corresponding external hamiltonian cycle C and apply our basic technique from section 2 to achieve 1-bend drawings. On the other hand, if G has a mapping M : V

P on the points of the horizontal line L such that a 1-bend drawing D ( G ) exists, there is clearly no edge which crosses line L . Otherwise, it would bend twice. Let w.l.o.g.

M be the mapping such that M ( v i

) = p i for i = 1 , . . . , n

Hence we can easily extend the embedding of G by edges between any vertex v i and v i

+1 for i = 1 , . . . , i

1 if necessary. such that this extension completes a hamiltonian path. The last (external) edge between v n and v

1 completing the hamiltonian cycle can also be inserted if it does not already exist. This

.

proves the NP-hardness of the drawing problem.

From the ‘equivalence’ of the problem to make G (external) hamiltonian and the 1-bend drawability problem for G with a set of points on a straight line we derive that the latter problem is in NP since like the hamiltoneancycle problem, the extensibility problem is in NP.

6 Discussion

One might argue that we are cheating regarding the lower bound example since all points with the same y -coordinate contradict the commonly used assumption of a general position of the points. On the other hand, the scenario seems quite realistic. If the objects (vertices) are required to be arranged in linear order horizontally or vertically, we get exactly the given set of points which we have already proved to be hard. Open problems:

1. Improve the area bounds, especially for the general case.

2. Extend the lower bound proof and the NP-completeness result to a set of points in general position.

3. Note that the complexity of the no-bend variant is still open, although

NP-completeness is also conjectured [1].

M. Kaufmann and R. Wiese, Few Bends ,

JGAA

, 6(1) 115–129 (2002) 128

References

[1] Bose, P., On Embedding an Outer-Planar Graph in a Point Set, in: G. DiBattista (ed.), Proc. 5th Intern. Symposium on Graph Drawing (GD’97), LNCS

1353, Springer 1998, pp. 25-36.

[2] Bose, P., M. McAllister, and J. Snoeyink. Optimal algorithms to embed trees in a point set.

Journal of Graph Algorithms and Applications 1998.

[3] Castaneda, N. and J. Urrutia., Straight line embeddings of planar graphs on point sets.

Proc. 8th Canadian conf. on Comp. Geom.

, pp. 312-318, 1996.

[4] Chiba, N., and T. Nishizeki, Arboricity and subgraph listing algorithms,

SIAM J. Comput.

14 (1985), pp. 210–223.

[5] Chiba, N., and T. Nishizeki, The hamiltonian cycle problem is linear-time solvable for 4-connected planar graphs, J. Algorithms 10 (1989), pp. 189-211.

[6] Chvatal, V., The traveling salesman problem, J. Wiley and Sons, 1985, pp.

426.

[7] Di Battista, G., Eades, P., Tamassia R. and I.G. Tollis, Algorithms for Automatic Graph Drawing: An Annotated Bibliography , Brown Univ., Tech. Rep.,

1993.

[8] Feige, U., Approximation the bandwidth via volume respecting embeddings.

Proc. 30th Annual ACM Symp. on Theory of Computing , 1998, pp. 90-99.

[9] Garey, M.R., D.S. Johnson, The Rectilinear Steiner Tree Problem is NPcomplete, SIAM J. Appl. Math.

32

(1977), pp. 826-834.

[10] Garey, M.R., D.S. Johnson and L. Stockmeyer, Some simplified NP-complete graph problems, Theoret. Comp. Science 1 (1976), pp. 237–267.

[11] Gritzmann, P., Mohar, B., Pach, J. and Pollack, R. Embedding a planar triangulation with vertices at specified points. in: American Mathematical

Monthly 98 (1991), pp. 165-166. (Solution to problem E3341).

[12] Ikebe Y., M. Perles, A. Tamura and S. Tokunaga, The rooted tree embedding problem into points in the plane, Discr. and Comp. Geometry 11 (1994), pp.

51–63.

[13] Lengauer, Th., Combinatorial Algorithms for Integrated Circuit Layout , Wiley, 1990.

M. Kaufmann and R. Wiese, Few Bends ,

JGAA

, 6(1) 115–129 (2002) 129

[14] Leighton, F.T., Parallel Algorithms and Architectures: Arrays-Trees-

Hypercubes , Morgan Kaufmann, 1992.

[15] Pach J. and R. Wenger, Embedding Planar Graphs at Fixed Vertex Locations, in: Sue Whitesides (ed.), Proc. 6th Intern. Symposium on Graph Drawing

(GD’98), LNCS 1547, Springer 1999, pp. 263-274.

Planar Graphs , vol. 9 of DIMACS Series, pages 131-137, 1993.

[17] Papadimitriou, Ch., The NP-completeness of the bandwidth minimization problem, Computing , 16(3), 1976, pp. 263–270.

Download