Algorithmica (2005) 42: 159–197 DOI: 10.1007/s00453-004-1132-z
Algorithmica © 2005 Springer Science+Business Media, Inc.
Drawing Planar Graphs Symmetrically, II: Biconnected Planar Graphs1 Seok-Hee Hong2 and Peter Eades2 Abstract. Symmetry is one of the most important aesthetic criteria in graph drawing because it reveals the structure in the graph. This paper discusses symmetric drawings of biconnected planar graphs. More specifically, we discuss geometric automorphisms, that is, automorphisms of a graph G that can be represented as symmetries of a drawing of G. Finding geometric automorphisms is the first and most difficult step in constructing symmetric drawings of graphs. The problem of determining whether a given graph has a nontrivial geometric automorphism is NP-complete for general graphs. In this paper we present a linear time algorithm for finding planar geometric automorphisms of biconnected planar graphs. A drawing algorithm is also discussed. Key Words. Graph drawing, Graph automorphism, Symmetry, Planar graphs.
1. Introduction. Graph drawing is constructing a visually informative drawing of an abstract graph in the plane. Symmetry is one of the most important aesthetic criteria that represent the structure and properties of a graph visually [5]. Also, a symmetric drawing of a graph enables an understanding of the entire graph to be built up from that of a smaller subgraph. Symmetric drawings of a graph G are clearly related to the automorphisms of G (the relationship is discussed below), and algorithms for constructing symmetric drawings have two steps: Step 1. Find the “appropriate” automorphisms, and Step 2. Draw the graph displaying these automorphisms as symmetries. Section 2.3 of this paper defines the “geometric automorphisms” of a graph, which are the “appropriate” automorphisms mentioned in the first step above. Intuitively, an automorphism of a graph G is “geometric” if it can be represented as a symmetry of a drawing of G. The concept of geometric automorphism can be refined to the concept of “planar geometric automorphism” (“planar automorphism”, in short). We describe an algorithm for finding planar automorphisms. The second step, constructing a drawing which displays the planar automorphisms, is much easier than the first, and is briefly described at the end of this paper. 1
This research has been supported by the Australian Research Council. NICTA (National Information and Communication Technology, Australia), and University of Sydney, Sydney, NSW 2006, Australia.
[email protected].
[email protected]. 2
Received April 3, 2002; revised July 13, 2004. Communicated by M.-Y. Kao. Online publication March 30, 2005.
160
S.-H. Hong and P. Eades
We should note that although the problem of finding a planar automorphism is related to, but not equivalent to, the problem of finding automorphisms, the problem of determining whether a graph has a non-trivial automorphism is automorphism complete [23]. However, the problem of determining whether a graph has a non-trivial geometric automorphism is NP-complete [25]; it is probably strictly harder than graph automorphism. Heuristics for constructing symmetric drawings of general graphs have been suggested by Lipton et al. [22], de Fraysseix [9], and Buchheim and Junger [3]. For restricted classes of graphs, there are polynomial time algorithms for constructing symmetric drawings. For example, Manning and Atallah present algorithms for finding geometric symmetries in trees [26], outerplanar graphs [27], and embedded planar graphs [25]; Hong et al. give algorithms for finding the maximum number of symmetries in seriesparallel digraphs [14]. This paper is the second in a series that gives symmetric drawing algorithms for planar graphs. Triconnected planar graphs are dealt with in [15], and graphs which are one-connected or disconnected are dealt with in [11] and [12]. This paper presents a linear time algorithm for drawing biconnected planar graphs with the maximum number of symmetries. A quadratic time algorithm for finding planar automorphisms in planar graphs has appeared [13, 10]. Here we present a linear time algorithm. The following theorem summarizes our main result. THEOREM 1. There is a linear time algorithm that constructs maximally symmetric planar drawings of biconnected planar graphs, with straight-line edges. The proof of Theorem 1 consists of two steps: a symmetry finding algorithm in Section 3 and a symmetric drawing algorithm in Section 7. Outputs of the algorithm are illustrated in Figure 1. Figure 1(a) shows a rotational symmetry by 180◦ and Figure 1(b) shows an axial symmetry. Figure 1(c) displays four rotational and four axial symmetries. In the next section we review the background: graph drawing, automorphisms of graphs, symmetries of drawings of graphs, the concept of planar automorphisms, the SPQR tree, and the triconnected case. Section 3 outlines the basic approach of our main algorithm for finding planar automorphisms of biconnected planar graphs. In Sections 4–6
(a)
(b) Fig. 1. Example output of the algorithm.
(c)
Drawing Planar Graphs Symmetrically, II
161
we describe each of the subroutines in turn. In Section 7 we describe the symmetric drawing algorithm and Section 9 concludes.
2. Background 2.1. Graph Drawing. If G = (V, E) is a graph, then a drawing of G consists of a distinct location p(v) for each vertex v ∈ V and a curve c(e) for each edge e = (u, v) ∈ E such that the endpoints of c(e) are p(u) and p(v). The drawing is planar if for every pair e, f of distinct edges that do not share a vertex, c(e) and c( f ) do not intersect. A graph is planar if it admits a planar drawing. A planar drawing of a graph divides the plane into regions called faces. The incidence relationship between vertices, faces, and edges is an embedding, or topological embedding, of the graph. A number of algorithms for constructing embeddings and drawings of planar graphs are described in [5]. 2.2. Automorphisms and Isomorphism Partitions. An isomorphism between two simple (at most one edge between each pair of vertices) graphs G 1 = (V1 , E 1 ) and G 2 = (V2 , E 2 ) is a one–one function ϕV from V1 onto V2 which preserves adjacency. That is, (u, v) ∈ E 1 if and only if (ϕV (u), ϕV (v)) ∈ E 2 . If G 1 = G 2 , then ϕ is an automorphism. This definition can be extended to non-simple graphs by adding a function between edge sets E 1 and E 2 . The set of automorphisms of a graph forms a group, and a subgroup of this group is an automorphism group. The graph isomorphism problem is to determine whether there is an isomorphism between two given graphs G 1 and G 2 . If G 1 = G 2 , then the isomorphism problem is the graph automorphism problem. Problems which are polynomial time equivalent to the graph isomorphism problem are called isomorphism complete problems. For example, the problem of counting the number of isomorphisms between two graphs is isomorphism complete [28]. A coloring of G consists of an assignment of a color C(v) to some of the vertices of G as well as the assignment of a color C(e) to some of the edges of G. An isomorphism ϕ from G 1 to G 2 respects the colours if C(ϕ(v)) = C(v) for each colored vertex v and C((ϕ(u), ϕ(w))) = C((u, w)) for each colored edge e = (u, w) of G. Coloring is useful in forcing an isomorphism to map specific vertices and edges to specific vertices and edges. Automorphisms of a graph are permutations of the vertices, and some of the terminology of permutation groups is helpful [30]. Suppose that a permutation group A acts on a set V . We say that ϕ ∈ A fixes v ∈ V if ϕ(v) = v; if ϕ fixes v for every ϕ ∈ A, then A fixes v. If V ⊆ V and ϕ(v ) ∈ V for all v ∈ V , then ϕ fixes V (setwise). A subset V of V is an orbit of A if, for each u, v ∈ V , there is ϕ ∈ A such that ϕ(u) = v, and V does not contain a non-empty subset with this property. The orbits of A form a partition of V , called the automorphism partition. The graph isomorphism problem can be solved in linear time for planar graphs [21]. Hopcroft and Tarjan [17]–[19] present an algorithm to test the isomorphism of planar graphs. It proceeds by reducing the problem to the triconnected case [17]; we adopt a similar approach. The algorithm [18], [19] also computes automorphism partitions
162
S.-H. Hong and P. Eades
(essentially, the vertex set is partitioned into the orbits of the automorphism group) of planar graphs as part of the isomorphism test in O(n log n) time. Later, Hopcroft and Wong [21] reduce the time complexity to linear, albeit with a large constant. Fontet [8] presents another linear time algorithm which also computes automorphism partitions. Suppose that G = {G 1 , G 2 , . . . , G k } is a set of planar graphs. The methods to test isomorphism [19], [21] can be used to produce “isomorphism partitions”, that is, partition G into sets of isomorphic graphs. In other words, we can assign a positive integer code(G i ) to each G i ∈ G with 1 ≤ code(G i ) ≤ k, such that code(G i ) = code(G j ) if and only if G i is isomorphic to G j . The isomorphism partition is useful for drawing graphs symmetrically; intuitively, if G i and G j are subgraphs of G such that G i is isomorphic to G j , then we can draw G i congruently to G j . The following lemma can be derived from [21]. LEMMA 1 [21]. Suppose that G 1 , G 2 , . . . , G k are planar graphs with colored vertices and edges. Then in linear time we can compute positive integers code(G 1 ), code(G 2 ), . . . , code(G k ) such that code(G i ) = code(G j ) if and only if there is an isomorphism from G i to G j that respects the colors. 2.3. Symmetries and Geometric Automorphisms. It is important to use a rigorous model for the intuitive concept of symmetry display. The model below is derived from those introduced by Eades and Lin [7]. The symmetries of a set of points in the plane (such as a two-dimensional graph drawing) form a group called the symmetry group of the set. A symmetry σ of a drawing D of a graph G induces an automorphism of G, in that the restriction of σ to the points representing vertices of G is an automorphism of G. A drawing D of a graph G displays an automorphism ϕ of G if there is symmetry σ of D which induces ϕ. The symmetry group of a graph drawing induces an automorphism group of the graph. An automorphism group A of a graph G is a geometric automorphism group if there is a drawing of G which displays every element of A. To understand the difference between automorphisms and geometric automorphisms, consider Figure 2 (from [7]). Figure 2(a) shows the graph K 2,3 . The permutation (123)(45) is an automorphism but not a geometric automorphism; in fact, the automorphism group of K 2,3 has size 12, but the only non-trivial geometric automorphism is the one displayed in Figure 2(a), that is, (13)(45).
1
2
1 0 0 1
3
1 0 0 1
1 0 0 1
1 0 0 1
1 0 0 1
1 0 0 1
1 0 0 1
1 0 0 1
1 0 0 1 1 0 0 1
1 0 1 0
5
4 (a)
1 0 0 1
(b)
Fig. 2. Three drawings with different symmetries.
1 0 0 1
(c)
Drawing Planar Graphs Symmetrically, II
163
A non-trivial symmetry of a finite set of points in the plane is either a rotation about a point or a reflection about a line. A geometric automorphism is a rotational automorphism (respectively axial automorphism) if it is induced by a rotation (respectively reflection). Eades and Lin [7] showed that that a non-trivial geometric automorphism group is one of three kinds: 1. a group of size 2 generated by an axial automorphism; 2. a cyclic group of size k generated by a rotational automorphism; 3. a dihedral group of size 2k generated by a rotational automorphism of order k and an axial automorphism. For example, Figure 1(a) displays a cyclic group of size 2 and Figure 1(b) displays a group of size 2 generated by an axial automorphism. Figure 1(c) displays a dihedral group of size 8. The ways in which geometric automorphism groups can be combined is not as simple as for automorphism groups. It is trivial to see that the union of two automorphism groups generates an automorphism group; thus there is a single maximal automorphism group. However, the union of two geometric automorphism groups does not necessarily generate a geometric automorphism group. This is shown by Figure 2(b), (c). The graph K 4 has a geometric automorphism group of size 8 (Figure 2(b)), and a geometric automorphism group of size 6 (Figure 2(c)). However, these groups do not combine to make a geometric automorphism group; each is maximal in that it cannot be made larger. In fact, Figure 2(b) displays eight geometric automorphisms; this is the maximum size for a geometric automorphism group of K 4 . Our aim is to find drawings with a maximum number of symmetries, and this means finding a maximum size geometric automorphism group. One can deduce from Manning’s work [25] that, in general, this problem is NP-hard. In this paper we consider a restriction of the problem to planar graphs, as described in the next section. 2.4. Planar Automorphisms. The concepts in Section 2.3 can be extended to planar drawings: a geometric automorphism ϕ of a graph G is planar if there is a planar drawing D of G which displays ϕ, and an automorphism group A is a planar automorphism group if there is a planar drawing which displays A. Not every geometric automorphism is planar. For example, the rotational automorphism displayed in Figure 2(b) is not planar; the largest planar automorphism group of K 4 , displayed in Figure 2(c), has size 6. The central problem of this paper is to find a planar automorphism group of maximum size. PLANAR AUTOMORPHISM PROBLEM Input: A planar graph G. Output: A planar geometric subgroup P of the automorphism group of G, such that P has maximum size. Previous research on the Planar Automorphism Problem has concentrated on subclasses of planar graphs. For example, an algorithm of Manning [25] finds planar automorphisms of a fixed planar embedding (with a fixed outside face) in linear time. In
164
S.-H. Hong and P. Eades
general, a biconnected planar graph can have an exponential number of planar embeddings, and it is not clear how to use Manning’s algorithm for planar graphs in general. Our aim is to give an efficient algorithm for planar graphs in general. For this, we use connectivity to divide the Planar Automorphism Problem into cases: 1. 2. 3. 4.
Triconnected graphs: a linear time algorithm is presented in [15]. Biconnected graphs: this is the topic of this paper. One-connected graphs: see [11]. Disconnected graphs: see [12].
The algorithm from [15] for the triconnected case is briefly reviewed in Section 2.6. Triconnected planar graphs have a unique embedding on the sphere, and this makes the Planar Automorphism Problem a little easier. For the biconnected, one-connected, and disconnected cases, we have developed algorithms that take for input a graph with vertices and edges possibly labeled, and return planar automorphism groups for the graph, as well as (possibly) some labels for the vertices and edges. Each of these cases relies on the result of the previous (higher connectivity) case. 2.5. The Rooted SPQR Tree. In this section we review the definition of triconnected components [20] (or 3-blocks) and a variation of the SPQR tree [6] of a biconnected graph. First we review the definition of triconnected components [20]. If G is triconnected, then G itself is the unique triconnected component of G. Otherwise, let u, v be a separation pair of G. We split the edges of G into two disjoint subsets E 1 and E 2 , such that |E 1 | > 1, |E 2 | > 1, and the subgraphs G 1 and G 2 induced by E 1 and E 2 only have vertices u and v in common. Form the graph G 1 by adding an edge (called a virtual edge) between u and v; similarly form G 2 . We continue the splitting process recursively on G 1 and G 2 . The process stops when each resulting graph reaches one of three forms: a triconnected simple graph, a set of three multiple edges (a triple bond), or a cycle of length three (a triangle). The triconnected components of G are obtained from these resulting graphs: 1. a triconnected simple graph; 2. a bond, formed by merging the triple bonds into a maximal set of multiple edges; 3. a polygon, formed by merging the triangles into a maximal simple cycle. The triconnected components of G are unique. See [20] for further details. One can define a tree structure, sometimes called the 3-block tree, using triconnected components as follows. The nodes of the 3-block tree are the triconnected components of G. The edges of the 3-block tree are defined by the virtual edges, that is, if two triconnected components have a virtual edge in common, then the nodes that represent the two triconnected components in the 3-block tree are joined by an edge that represents the virtual edge. There are many variants of the 3-block tree in the literature; the first was defined by Tutte [29]. In this paper we use the terminology of the SPQR tree, as defined by di Battista and Tamassia [6]. We now briefly review this terminology.
Drawing Planar Graphs Symmetrically, II
165
Each node v in the SPQR tree is associated with a graph called the skeleton of v, denoted by skeleton(v), which corresponds to a triconnected component. There are four types of nodes in the SPQR tree. The node types and their skeletons are: 1. Q-node: the skeleton consists of two vertices connected by two multiple edges. Each Q-node corresponds to an edge of the original graph. 2. S-node: the skeleton is a simple cycle with at least three vertices (this corresponds to a polygon triconnected component). 3. P-node: the skeleton consists of two vertices connected by at least three edges (this corresponds to a bond triconnected component). 4. R-node: the skeleton is a triconnected graph with at least four vertices. In fact, we use a slight modification of the SPQR tree: we omit the Q-nodes and we root the tree as described below. We refer to the modified SPQR tree as the SPQR tree throughout this paper. An example is illustrated in Figure 3. A biconnected planar graph in Figure 3(a) can be divided into triconnected components as in Figure 3 (b) (from [20]). Here, B, D, F, and H are P-nodes and C, E, and I are S-nodes, and A, G, and J are R-nodes. The SPQR tree is illustrated in Figure 3(c). We need to choose a root for the SPQR tree. A node c (or edge e) of a tree T is a center of T if the maximum distance from c (respectively e) to every node is minimized. A tree either has a unique center node or a unique center edge. The center can be found in linear time by a simple leaf-pruning algorithm. The center of the SPQR tree in Figure 3(c) is an edge between nodes D and E. The rooted SPQR tree is rooted at the center. Some further notation for the SPQR tree is required. Suppose that G is a biconnected (but not triconnected) planar graph, and T is the rooted SPQR tree of G. Let v be a node
10
11
10
11
9
A
9
12
8
p
12
E
D 8
p 12
B
8
q 5
1
q
12
8
C
r 13 2
1
H
r
1 4
D
8
I
s
s 3
F C
6
7
1
8
E
(a)
5
4 1
t
x
1
4
5
u
w
2
J
t
1
13
w
v
x
u
4 7
3
J
F
5
A
9
G
4 3
G
B
v
4
I
6
H
(b)
Fig. 3. An example of the SPQR tree.
(c)
166
S.-H. Hong and P. Eades 00 11 11 00 00 11
1 0 1 0
11 00 00 11
1 0 1 0
1 0 1 0
1 0 0 1 1 0 1 0 1 0
11 00 11 00
(a)
1 0 1 0
1 0 1 0
(b)
11 00 00 11 00 11
1 0 0 1 0 1
1 0 0 1 0 1
11 00 11 00 00 11 11 00 00 11
1 0 0 1
1 0 0 1
00 11 11 00 00 11
11 00 00 11 11 00 00 11
(c)
Fig. 4. Examples of skeleton(v) and skeleton− (v).
in T and say u is the parent of v. The graph skeleton(u) has one virtual edge e in common with skeleton(v). The edge e is the parent virtual edge in skeleton(v) and it is a child virtual edge in skeleton(u). We define a parent separation pair of v as the two endpoints of a parent virtual edge e. For each non-root node v of the SPQR tree, skeleton(v) has precisely one parent virtual edge, and for each non-leaf node w, skeleton(w) has at least one child virtual edge. We denote the graph formed from skeleton(v) by deleting its parent virtual edge as skeleton− (v), if v is not the root of T . The union of the graphs skeleton− (u) for all descendants u of v, including v itself, is denoted by G + (v). Examples of skeleton(v) and skeleton− (v) are illustrated in Figure 4; the parent virtual edges are dashed. Figure 4(a) shows an example of skeleton(v) and skeleton− (v) when v is a P-node. Figure 4(b) shows an example of skeleton(v) and skeleton− (v) when v is an Snode. Figure 4(c) shows an example of skeleton(v) and skeleton− (v) when v is an R-node. It is worth mentioning at this stage that we do not need to use the full facilities of the SPQR tree as developed by di Battista and Tamassia [6]. Their SPQR tree is an efficient data structure, with efficient operations. In this paper, however, we do not use any of these efficient operations; we only use the rooted SPQR tree as a convenient decomposition of a biconnected graph into triconnected components. Traversing the tree level-by-level from the maximum level to the root traverses the triconnected components. 2.6. Finding Planar Automorphisms in Triconnected Planar Graphs. Hong et al. [15] present an algorithm for finding a maximum size planar automorphism group of triconnected planar graphs in linear time. We briefly describe their approach. Let G be a triconnected planar graph. Note that a planar automorphism fixes a face. The algorithm of [15] takes the dual graph G of G and then computes the orbits of G using Fontet’s algorithm [8]. Using the orbit-stabilizer theorem [1], the algorithm finds a plane embedding of G that has the maximum size planar automorphism group. Generators of the planar automorphism group of G with given plane embedding are then derived. The algorithm of [15] works for colored plane graphs. Hong et al. [15] also give a linear time drawing algorithm. This takes a graph G and a planar automorphism group A of G and draws G with straight-line edges to display A. The current paper uses both the symmetry finding algorithm and the symmetric drawing algorithm of [15].
3. Outline of the Symmetry Finding Algorithm. This section gives an outline of the algorithm for finding planar automorphisms in biconnected planar graphs. Details of the algorithm are developed in subsequent sections.
Drawing Planar Graphs Symmetrically, II
167
The algorithm computes the rooted SPQR tree, and traverses the triconnected components of the input graph by traversing the nodes of the rooted SPQR tree. The reason for using the rooted SPQR tree is that this decomposition into triconnected components is unique [6], and thus, intuitively, automorphisms of the input graph come from automorphisms of the rooted SPQR tree. The traversal of the SPQR tree is a kind of “reduction” [19] process, from the leaves of the SPQR tree that are furthermost from the root, up to the root. An outline of the algorithm follows: Algorithm Biconnected Planar 1. Construct the SPQR tree T of G, and root T at its center. 2. Reduction and labeling. For each level (graph theoretic distance from the root) i of T , from the lowest level to the root (but not including the root): For each node v on level i: (a) Compute labels for its parent virtual edge e of skeleton(v); the labels are integer and boolean values that identify some of the symmetry properties of G + (v). (b) Transfer the labels to the corresponding child virtual edge e in skeleton(u), where u is the parent of v. 3. Compute and output a maximum size planar automorphism group of the graph, using the labels at the center (that is, the root) computed by reduction. For the first step of Biconnected Planar, note that the rooted SPQR tree can be computed in linear time by the algorithm of [20]; we do not discuss this step further. The reduction and labeling process at the second step of Biconnected Planar is motivated by the following observation. Suppose that G is a biconnected planar graph, and T is its rooted SPQR tree. Suppose that G is not triconnected and the leaves of T at the maximum level are v1 , v2 , . . . , vk . Form a graph G from G by replacing each graph skeleton(vi ) with an edge ei . We say that G is the reduction of G. An example is illustrated in Figure 5. The graph G in Figure 5(a) results in G as in Figure 5(c) by the reduction process in Figure 5(b). Suppose that ϕ is an automorphism of G. Note that for each i, any automorphism of G maps skeleton(vi ) to skeleton(v j ) for some j (see [2]). We define an automorphism ϕ of G as follows: if ϕ maps skeleton(vi ) to skeleton(v j ), then ϕ maps ei to e j . For every other vertex or edge x of G , ϕ maps x to ϕ(x). We say that ϕ is the restriction of ϕ to G . Note that the center of the SPQR tree is always fixed by any automorphism [2]; this is why the root is chosen to be the center. Further, the reduction process preserves the planar automorphisms of the graph, as described in Lemma 2 below. LEMMA 2. Let be a planar automorphism group of a biconnected planar graph G, and suppose that G is the reduction of G. Then the restriction ϕ of each ϕ ∈ to G is a planar automorphism of G . Further, the group = {ϕ : ϕ ∈ } is isomorphic to .
168
S.-H. Hong and P. Eades
u1 w5 skeleton( v5 )
e5
skeleton( v4 )
(a)
u1
e1
u4
e1
w1 w1
w5
e u5 5 u5 w4 w4 e4
skeleton( v1) e1
u u2 2 skeleton( v2 ) e2 e2 e
w5
w2 w2
u5
5
e4
u2
u3
u3 u4 w e3 3 e3 w3 skeleton( v3 ) (b)
w1
u1
w2 u3
w4 e4
w3
u4
e3
(c)
Fig. 5. Example of the reduction process.
PROOF. Suppose that the leaves of T at the maximum level are v1 , v2 , . . . , vk , and G is formed from G by replacing each graph skeleton(vi ) with an edge ei . Denote the graph formed from G by deleting all the edges ei by G ; note that G is a subgraph of G. Since ϕ is a planar automorphism of G, there is a drawing D of G which displays ϕ. One can construct a planar drawing D of G which displays ϕ , by replacing the drawings of skeletons by drawings of edges. It is clear that both ϕ and planarity can be preserved; it follows that ϕ is a planar automorphism of G . We claim that the mapping ϕ → ϕ is an isomorphism from to . If not, then there is a non-identity element ϕ ∈ such that ϕ is the identity. Note that ϕ fixes every vertex of G , but it is not the identity. It follows that G must be either empty, or a single vertex, or a set of disjoint paths. However, G is biconnected and so this is impossible. Lemma 2 shows that the reduction process does not “reduce” the planar automorphism group. This is not enough; we also need to ensure that the planar automorphism group is not “increased” by reduction. This is the role of the labels, discussed in the next few sections. As skeleton(v) is deleted, a labeling algorithm labels the corresponding child virtual edge in the parent. These labels are described in detail in Section 4; roughly speaking, they encode information about the deleted skeleton(v) to ensure that planar automorphisms of the labeled reduced graph extend to planar automorphisms of the original graph. The labeling algorithms are given in Section 5. The final step of Biconnected Planar computes the maximum size planar automorphism group at the center. The reduction process stops when it reaches the root, that is, the center of the SPQR tree. The center is either a node (R-node, S-node, or P-node) or an edge (a separation pair). Algorithms for this step are described in Section 6. The main result of this paper is the following theorem. THEOREM 2. Biconnected Planar computes a maximum size planar automorphism group of a biconnected planar graph in linear time.
e2
Drawing Planar Graphs Symmetrically, II
169
The proof of Theorem 2 occupies most of the remainder of this paper. Essentially this consists of giving detailed descriptions of algorithms for each step of Biconnected Planar. Using these algorithms, the proof of the theorem is given in the last subsection of Section 6. After Algorithm Biconnected Planar computes the maximum size planar automorphism group, we draw the graph to display the group. A linear straight-line drawing algorithm is described in Section 7.
4. The Labels. The aim of labeling is to give a kind of converse to Lemma 2, and thus to compute the maximum size planar automorphism group of the original graph by computing the maximum size planar automorphism group of the labeled center. In this section we define the labels and describe some of their properties; Sections 5.1–5.3 give the algorithms for computing the labels. We use the following notation throughout this section. Suppose that nodes v1 , v2 , . . . , vk of the SPQR tree are deleted at one iteration of the reduction process. These nodes correspond to virtual edges e1 , e2 , . . . , ek in the level above the current level, and e j = (u j , w j ) for each j. First we discuss standard labels in Section 4.1, and then special labels in Section 4.2. 4.1. Standard Labels. We need to compute the following four “standard” labels for each e j : an isomorphism partition label IP(e j ), two axial labels Aswap (e j ) and Afix (e j ), and a 180◦ rotation label R180 (e j ). In the next three subsections we define these labels and explain why they are necessary to compute planar automorphisms. First we explain isomorphism partition labels. 4.1.1. Isomorphism partition labels. If G + (vi ) and G + (v j ) are isomorphic, then they can be drawn congruently, and a symmetry of the drawing may map one to the other. We assign an “isomorphism partition label” to each e j , related to the integer code in Lemma 1. For example, consider Figure 6(a): if G + (v1 ), G + (v2 ), and G + (v3 ) are isomorphic, then there is possibly a rotational planar automorphism which maps G + (v1 ) to G + (v2 ), G + (v2 ) to G + (v3 ), and G + (v3 ) to G + (v1 ). The reduction step labels e j with an isomorphism partition label, resulting in a graph such as in Figure 6(b). By testing the graph in Figure 6(b) for rotational automorphisms that respect the isomorphism partition labels, we can test the original graph for rotational automorphisms. Note that such an isomorphism should also map the separation pairs that attach the G + (vi ) to their parent to each other. The kind of isomorphism code in Lemma 1 is not sufficient for this; we need an ordered pair of integers. This is because each G + (vi ) has an orientation with respect to its separation pair. Consider Figure 7: if the isomorphism code were a single integer, then the graphs in both Figures 7(a) and (c) would reduce to the same labeled graph (Figure 7(b)); this misrepresents their automorphisms. Formally, the isomorphism partition label IP has two defining properties. Suppose that IP(e j ) = (a j , b j ) for each j. Then for any pair of nodes vi , v j that are deleted in one
170
S.-H. Hong and P. Eades G+v 1
IP(e1 )
G+v 2
IP(e2
IP( e ) 3
G+v 3 (b)
(a)
Fig. 6. Example of isomorphism partition labels.
iteration of the reduction process, the following properties hold: P1. There is an isomorphism ι : G + (vi ) → G + (vk ) such that ι(u i ) = u k and ι(wi ) = wk if and only if ai = ak and bi = bk . P2. There is an isomorphism ι : G + (vi ) → G + (vk ) such that ι(u i ) = wk and ι(wi ) = u k if and only if ai = bk and bi = ak . Isomorphism partition labels, along the lines of those described above, are used in planar graph isomorphism algorithms [19], [21]. In the next two sections we introduce more labels that are needed for finding planar automorphisms. 4.1.2. Axial labels. In this section we introduce labels to encode the existence of axial planar automorphisms. Note that the two properties P1 and P2 of isomorphism partition labels in Section 4.1.1 imply that G + (v j ) has an automorphism that swaps u j and w j if and only if a j = b j . However, the existence of such an automorphism does not imply the existence of an axial planar automorphism of G + (v j ). We need to divide the types of axial automorphism into two cases, depending on
+ Gv 2
+ Gv 2
IP( e ) 2
G+ v 1
G+ v 1
G v+ 3
G+ v 4 (a)
IP( e ) 3
G v+ 3
IP( e ) 1 IP( e ) 4
+ Gv 4
(b)
Fig. 7. Examples of the orientation for the isomorphism partition labels.
(c)
Drawing Planar Graphs Symmetrically, II
171
v + G
Gv
2
e2
1
e1
G+ v
e
3
(a)
3
(b) Fig. 8. Example of the Aswap label.
whether the planar automorphism swaps its separation pair, or fixes the separation pair elementwise. We use a label Aswap (e j ) to indicate whether G + (v j ) has an axial planar automorphism that swaps endpoints of e j . This is illustrated in Figure 8. In Figure 8(a) if G + (v1 ) has an axial planar automorphism that swaps its separation pair, then (assuming that G + (v2 ) is isomorphic to G + (v3 )) the whole graph may have an axial planar automorphism. By testing Aswap (e1 ) in Figure 8(b), we can test whether the whole graph has an axial planar automorphism. More formally, Aswap (e j ) is a boolean label which is true if and only if there is a drawing D of G + (v j ) with u j and w j on the outside face, such that D has an axial planar automorphism that swaps u j with w j . The requirement that u j and w j are on the outside face is necessary because G + (v j ) is not necessarily triconnected, and thus the embedding may not be unique. It is possible that G + (v j ) has axial planar automorphisms for embeddings in which u j and w j do not share a face; such automorphisms cannot be displayed in a planar drawing of G. Similarly we use a label Afix (e j ) to indicate whether G + (v j ) has an axial planar automorphism that fixes both endpoints of e j elementwise. This is illustrated in Figure 9. In Figure 9(a), if G + (v1 ) and G + (v2 ) have axial planar automorphisms that fix the
e1
G+v
1
+
Gv
e
2
2
(a)
Fig. 9. Example of the Afix label.
(b)
172
S.-H. Hong and P. Eades
separation pairs elementwise, then G may have an axial planar automorphism. By testing Afix (e1 ) and Afix (e2 ) in Figure 9(b), we can test whether the whole graph has an axial planar automorphism. More formally, Afix (e j ) is a boolean label which is true if and only if there is a drawing D of G + (v j ) with u j and w j on the outside face, such that D has an axial planar automorphism that fixes both u j and w j . For concrete examples of the axial labels, see Figure 10. The SPQR tree for Figure 10(a) is illustrated in Figure 10(b). Let c be the center of the SPQR tree. Here skeleton(c) has exactly the same planar automorphisms as the original graph if and only if IP(e1 ) = IP(e2 ) = IP(e3 ) = IP(e4 ), IP(e5 ) = IP(e6 ) = IP(e7 ) = IP(e8 ), Aswap (e1 ) = Aswap (e2 ) = Aswap (e3 ) = Aswap (e4 ) = true, and Afix (e5 ) = Afix (e6 ) = Afix (e7 ) = Afix (e8 ) = true. 4.1.3. Labels for rotation by 180◦ . The isomorphism partition label IP(e j ) captures much of the information needed to test whether the graph has rotational symmetry. However, we need another label for a rotation by 180 degrees; this is needed because a 180◦ rotation fixes the separation pair setwise. We use a label R180 (e j ) to indicate whether G + (v j ) has a rotational planar automorphism by 180◦ . This is illustrated in Figure 11; and suppose that IP(e1 ) is the reverse of IP(e2 ). The whole graph in Figure 11(a) can display a 180◦ rotational automorphism if and only if G + (v3 ) can display a 180◦ rotational automorphism. By testing R180 (e3 ) in Figure 11(b), we can test whether the whole graph has a 180◦ rotational automorphism. More formally, R180 (e j ) is a boolean label which is true if and only if there is a drawing D of G + (v j ) with u j and w j on the outside face, such that D has a rotational planar automorphism by 180◦ that swaps u j with w j . Note that if Afix (e j ) and Aswap (e j ) are both true, then R180 (e j ) is true. However, it is possible that R180 (e j ) is true, but Afix (e j ) and Aswap (e j ) are both false. Hence, we need the label R180 (e j ). A more specific illustration of rotation by 180◦ is in Figure 12. The SPQR tree for Figure 12(a) is illustrated in Figure 12(b). Let c be the center of the SPQR tree. Here
e1 e5 c
e2
e6
e8 e7
e3
(a)
(b)
Fig. 10. Example of the axial labels.
e4
Drawing Planar Graphs Symmetrically, II
173
e
G+ v 1 e
G+ v3 G+v 2
1
3
e
2
(b)
(a) Fig. 11. Example of the R180 label.
skeleton(c) has exactly the same planar automorphisms as the original graph if and only if IP(e1 ) is the reverse of IP(e2 ), and R180 (e3 ) = true. 4.2. A Special Case and Special Labels. The aim of labeling is to encode information about planar automorphisms and isomorphisms of the G + (v) of the non-root node v of the SPQR tree in the parent virtual edges. In this way we can find planar automorphisms of the whole graph by finding planar automorphisms of the labeled skeleton(c) of the root node c. This strategy has a simple flaw: the edges may not model the topological properties of the G + (v) of the non-root node v correctly. In particular, while the G + (v) of a child node v can enclose skeleton(u) of a parent node u (see Figure 13(a)), the child virtual edge e in skeleton(u) of parent node u (see Figure 13(b)) cannot enclose the skeleton(u), since it is purely a one-dimensional curve. An embedding in which skeleton(u) is on an inside face of G + (v), where u is the parent of v, is called an enclosing composition. Figure 14 shows a more concrete example. Figure 14(a) shows an example of a drawing constructed by an enclosing composition; this shows the maximum number of
e1 e3
c
e2
(a)
(b)
Fig. 12. Example of the R180 label.
174
S.-H. Hong and P. Eades + G(v) 000 111 000 111 000 111 000 111
skeleton(u)
e 000 111 000 111 000 111 000 111
000 111 000 111 000 111 000 111
(a)
skeleton(u)
000 111 000 111 000 111 000 111
(b)
Fig. 13. Enclosing composition: v is a child of u.
symmetries of a graph, two rotational and two axial symmetries. Figure 14(b) shows the SPQR tree of the graph. Here skeleton(c) of the root node c of the SPQR tree is enclosed by skeleton(v) of its child node v. The enclosing child node may be in turn enclosed by one of its children, again fixed setwise. Note that the graph can be drawn without enclosing nodes, based on skeleton(c), as in Figure 14(c); but this displays less symmetry, only one axial symmetry. As an aside, note that in this special case, all planar automorphisms fix both skeleton(u) and G + (v); this means that there is a separation pair which is fixed setwise by all planar automorphisms. This implies that a planar automorphism group of the graph has size at most 4. To take care of special cases such as that illustrated in Figure 14, we need special labels. The most important property of this special case is that the whole planar automorphism group fixes two faces of G + (v): the outside face and the internal face containing the separation pair. Thus we define the following labels: • A∗swap (e j ) is a boolean label that is true if and only if there is a drawing of G + (v j ) with an axial symmetry that swaps u j with w j , with u j and w j sharing an inside face. • A∗fix (e j ) is a boolean label that is true if and only if there is a drawing of G + (v j ) with an axial symmetry that fixes both u j and w j , with both u j and w j on an inside face.
c
v
(a)
(b) Fig. 14. The special case.
(c)
Drawing Planar Graphs Symmetrically, II
175
∗ • R180 (e j ) is a boolean label that is true if and only if there is a drawing of G + (v j ) with a rotational symmetry of 180◦ that swaps u j and w j , with both u j and w j on an inside face.
In fact, it is enough to require that the planar automorphism fixes two faces: one incident to u j and w j , and the other not incident to u j and w j , as described in the following lemma. LEMMA 3. Suppose that D is a drawing of a planar graph G and u and w are vertices of G that share a face in D. Suppose that D displays an axial planar automorphism ϕ that fixes {u, w}. Then ϕ fixes at least one face not incident to u and w if and only if there is a drawing D of G that displays ϕ, with u and w not on the outside face. PROOF. Suppose that D is a drawing of G that displays ϕ, where u and w are not on the outside face. Then ϕ fixes at least one face not incident to u and w, the outside face. Conversely, suppose that ϕ fixes one face F not incident to u and w. If u and w are not on the outside face of D, then we are done. If u and w are on the outside face of D, then we can convert D to a drawing D with F as an outside face using a “lifting” transformation, as follows. First use scaling to ensure that D is within the unit circle on the x y plane. Then apply a “lifting” projection from the plane to the surface of a hemisphere of radius one about the origin (that is, mapping (x, y) to (x, y, 1 − x 2 − y 2 )). This lifting preserves ϕ in the sense that the lifted drawing displays ϕ as a three-dimensional symmetry; note that this symmetry fixes F. Finally, apply a stereographic projection from the sphere back to the plane, about the center of the face F to form D . Since ϕ fixes F, this projection preserves symmetry; D displays ϕ. The face F is the outside face of D and thus u and w are not on the outside face. Lemma 3 implies, for example, that A∗swap (e j ) = true if and only if G + (v j ) has an axial planar automorphism that swaps u j with w j , fixes a face incident to the separation pair, and fixes at least one other face. Concrete examples are illustrated in Figures 15–17. Figure 15(a) shows a drawing with an enclosing composition and it displays an axial automorphism. Figure 15(b) shows the SPQR tree of the graph. Figure 15(c) shows a drawing without an enclosing composition; this displays no symmetry. Figure 16(a) shows a drawing with an enclosing composition and it displays an axial automorphism. Figure 16(b) shows the SPQR tree of the graph. Figure 16(c) shows a drawing without an enclosing composition, but this displays no symmetry. Figure 17(a) shows a drawing with an enclosing composition and it displays a 180◦ rotational automorphism. Figure 17(b) shows the SPQR tree of the graph. Figure 17(c) shows a drawing without an enclosing composition, but this displays no symmetry.
5. Labeling Algorithms. In this section we describe algorithms to compute the labels. There are different labeling algorithms depending on whether the node is an R-node, a P-node, or an S-node; these cases are dealt with in the subsequent sections.
176
S.-H. Hong and P. Eades
Fig. 15. Example of the A∗swap label.
(a)
(b)
(c)
Fig. 16. Example of the A∗fix label.
(a)
(b) ∗ label. Fig. 17. Example of the R180
(c)
Drawing Planar Graphs Symmetrically, II
177
111 000 000 111 000 111
111 000 000 111 000 111
f1 11 00 00 11 00 11
f1 f
2
11 00 00 11 00 11
f e
11 00 00 11 00 11
2
11 00 00 11 00 11
f
f
3
11 00 00 11 00 11
(a)
3
11 00 00 11 00 11
(b)
Fig. 18. Example of an R-node.
5.1. Labeling Algorithms for R-Nodes. In this section we describe the labeling algorithms for R-nodes, that is, how to compute the labels that are defined in the previous section when the node v is an R-node. An R-node and its contexts are illustrated in Figure 18. Figure 18(a) shows skeleton(v) and it consists of a number of child virtual edges, a parent virtual edge, and a number of real edges. The child virtual edges are labeled. Figure 18(b) shows skeleton− (v). We describe an algorithm for computing the isomorphism partition labels in Section 5.1.1, and algorithms for the axial labels and the rotation labels in Section 5.1.2. 5.1.1. Algorithm for isomorphism partition labels of R-nodes. Once again suppose that nodes v1 , v2 , . . . , vk of the SPQR tree are deleted at one iteration of the reduction process. These nodes correspond to virtual edges e1 , e2 , . . . , ek in the level above the current level, and e j = (u j , w j ) for each j. In this subsection we show how to compute IP(e j ) for each j. If ι is an isomorphism from skeleton(v j ) to skeleton(vk ) such that for each child virtual edge e j in skeleton(v j ), IP(e j ) = IP(ι(e j )), then we say that ι respects the isomorphism partition labels. Recall that the Hopcroft–Wong algorithm (Lemma 1) can be used to compute colored isomorphism partitions. Our algorithm colors vertices to ensure that isomorphisms respect the isomorphism labels on child virtual edges, and map parent separation pairs to parent separation pairs. A naive approach would be to apply Lemma 1 to compute an isomorphism partition of an appropriate coloring of the graphs G + (v1 ), G + (v2 ), . . . , G + (vk ); however, summing the time over all nodes of the SPQR tree would give quadratic time. Instead, we apply Lemma 1 to skeleton(v1 ), skeleton(v2 ), . . . , skeleton, (vk ), using coloring to guarantee properties P1 and P2 of Section 4.1.1. In this way the total computation time over all nodes of the SPQR tree is linear. The algorithm follows: Algorithm Compute Isomorphism Partition Label R-nodes 1. Assign colors to each child virtual edge in each skeleton(v j ) so that edges with the same isomorphism partition label have the same color. 2. Assign colors to each parent virtual edge so that they all have the same color. 3. For each j, make a copy skeleton (v j ) of skeleton(v j ); the copies of u j and w j are u j and w j , respectively.
178
S.-H. Hong and P. Eades
4. Assign a color c1 to each u j and w j , and a different color c2 to each w j and u j . 5. Apply the isomorphism partition algorithm (Lemma 1) to skeleton(v1 ), skeleton(v2 ), . . . , skeleton(vk ), skeleton (v1 ), skeleton (v2 ), . . . , skeleton (vk ), respecting the colors. 6. Using this partition, assign an isomorphism partition label IP(u i , wi ) to each parent virtual edge (u i , wi ) to satisfy the following: (a) If skeleton(vi ) and skeleton(v j ) are in the same class and IP(u i , wi ) = (a, b), then IP(u j , w j ) = (a, b). (b) If skeleton(vi ) and skeleton (v j ) are in the same class and IP(u i , wi ) = (a, b), then IP(u j , w j ) = (b, a). We now prove that the algorithm is correct and takes linear time. LEMMA 4. Compute Isomorphism Partition Label R-nodes correctly computes the isomorphism partition labels for the parent virtual edges in each skeleton(v j ) in time linear in the sum of the sizes of the skeleton(v j ). PROOF. Firstly note that when this algorithm is called, the isomorphism partition labels for each child virtual edge in each skeleton(v j ) have already been computed at the previous level in the main loop of Biconnected Planar. The isomorphism partition algorithm at step 5 (Lemma 1) runs in linear time, and all the other steps of the algorithm are trivially linear; thus the algorithm runs in linear time. Next we consider correctness. The algorithm consists of four preprocessing steps which color the skeletons, followed by the computation of the isomorphism partitions at step 5, followed by the label assignment. First consider the preprocessing steps 1–4. Step 1 ensures that the isomorphism partition at step 5 respects the isomorphism partition labels on child virtual edges. Step 2 ensures that an isomorphism computed at step 5 maps each child virtual edge {u i , wi } to a child virtual edge {u j , w j } (but we do not know whether u i is mapped to u j or w j ). The coloring at steps 3 and 4 further restricts the isomorphisms computed at step 5; these colors force the following two properties on the isomorphism partition: (a ) Skeleton(vi ) and skeleton(v j ) are in the same class if and only if there is an isomorphism from skeleton(vi ) to skeleton(v j ) that maps u i to u j and wi to w j . (b ) Skeleton(vi ) and skeleton (v j ) are in the same class if and only if there is an isomorphism from skeleton(vi ) to skeleton (v j ) that maps u i to w j and wi to u j . These two properties ensure that the computation of the pairs of integers for labels at step 6 is straightforward. If step 6 computes IP(u i , wi ) = (ai , bi ) and IP(u j , w j ) = (a j , b j ), then: (a ) there is an isomorphism ι : skeleton(vi ) → skeleton(v j ), respecting the isomorphism partition labels on the child virtual edges, such that ι(u i ) = u j and ι(wi ) = w j if and only if ai = a j and bi = b j , and (b ) there is an isomorphism ι : skeleton(vi ) → skeleton(v j ), respecting the isomorphism partition labels on the child virtual edges, such that ι(u i ) = w j and ι(wi ) = u j if and only if ai = b j and bi = a j .
Drawing Planar Graphs Symmetrically, II
179
A simple inductive argument can be used to show that the isomorphism ι in (a ), (b ) can be extended to an isomorphism from G + (vi ) to G + (v j ). Thus the partition labels computed at step 6 satisfy properties P1 and P2. This completes the proof of correctness.
5.1.2. Algorithm for axial labels and 180◦ rotation labels of R-nodes. Suppose that skeleton(v) is the 3-block associated with the node v of the SPQR tree T , and e = (u, w) is its parent virtual edge. In this subsection we show how to compute Afix (e), A∗fix (e), ∗ (e). Aswap (e), A∗swap (e), R180 (e), and R180 We say that an axial planar automorphism α respects the axial labels of skeleton− (v) if Afix ( f ) = true for each child virtual edge f in skeleton− (v) whose endpoints are fixed by α; and Aswap ( f ) = true, for each child virtual edge f in skeleton− (v) whose endpoints are swapped by α. Also, a 180◦ rotational planar automorphism β respects the 180◦ rotation label of skeleton− (v) if R180 ( f ) = true for the child virtual edge f in skeleton− (v) that is fixed by β. First we consider Afix (e) and A∗fix (e). To ensure linear time for the computation of Afix (e) and A∗fix (e), we must perform the computation on skeleton− (v) rather than on G + (v). The following lemma justifies this. LEMMA 5. The label Afix (e) is true if and only if there is a drawing D of skeleton− (v) that displays an axial planar automorphism α, with u and w on the outside face, such that the automorphism α: (a) fixes both u and w, (b) respects the isomorphism partition labels of skeleton− (v), and (c) respects the axial labels of skeleton− (v). The label A∗fix (e) is true if and only if, in addition to the three conditions above, at least one of the following properties holds: (d) α fixes more than one face of skeleton− (v), or (e) α fixes the endpoints of a child virtual edge f such that A∗fix ( f ) = true, or (f) α swaps the endpoints of a child virtual edge f such that A∗swap ( f ) = true. PROOF. Suppose that Afix (e) is true, that is, G + (v) has a drawing which displays an axial planar automorphism that fixes both u and w, with both u and w on the outside face. Properties (a)–(c) follow immediately. Conversely suppose that properties (a)–(c) hold for skeleton− (v). One can extend the drawing of skeleton− (v) to a drawing of G + (v) by replacing each child virtual edge f with a drawing of skeleton− (v f ) where v f is the child of v which corresponds to f ; properties (b) and (c) ensure that this can be done while preserving symmetries. In this way, a simple induction can be used to show that Afix (e) is true. From Lemma 3, A∗fix (e) is true if and only if Afix (e) is true and the axial planar automorphism of skeleton− (v) can be extended to an axial planar automorphism of G + (v) that fixes more than one face. Each one of conditions (d)–(f) implies that α can be extended to fix more than one face of G + (v). Conversely, if an extension α of α fixes more than one face of G + (v), then either (d) holds, or α fixes a face of G + (v) that is not in skeleton− (v). In this case, one can deduce that either (e) or (f) holds.
180
S.-H. Hong and P. Eades 111 000 000 111 000 111 000 111 000 111 111 000 000 111
00 11 11 00 00 11
00 11 11 00 00 11 00 11 11 00 00 11
11 00 00 11 00 11
000 111 111 000 000 111
00 11 11 00 00 11 000 111 111 000 000 111 000 111
000 111 111 000 000 111 00 11 11 00 00 11 00 11 00 11 11 00 00 11 00 11
00 11 11 00 00 11 000 111 00 111 11 000 11 00 000 00 111 11 000 111 111 000 000 111
11 00 00 11 00 11 000 111 111 000 000 111 000 111
(a)
(b)
Fig. 19. Augmentation using the star triangulation.
To apply Lemma 5, we need an algorithm for computing axial planar automorphisms of skeleton− (v). A linear time algorithm for computing planar automorphisms in triconnected planar graphs is given in [15] and [16]. This algorithm cannot be applied immediately to skeleton− (v) since, although skeleton(v) is triconnected, skeleton− (v) may be merely biconnected. However, because u and w are on the outside face, we can apply the algorithm of [15] and [16] by “augmenting” skeleton− (v), as follows. First, we find an embedding of skeleton(v) with the parent virtual edge e on the outside face. Then delete e to form an embedding of skeleton− (v) with u and w on the outside face. Suppose that the resulting graph has outside face (a1 , a2 , . . . , ak ); since skeleton− (v) is at least biconnected, all the ai are distinct. Now add a new outside face (a1 , a2 , . . . , ak ) and add edges (ai , ai ) for each i. Note that the new graph has the same planar automorphisms as skeleton− (v). Next triangulate every internal face of this new graph using “star triangulation”: 1. for each internal face F of the biconnected plane graph, add a new dummy vertex d, and 2. insert new edges from d to each vertex on the face F. This augmentation preserves planar automorphisms (see [15] and [16]), and the resulting graph is triconnected. Figure 19 shows an example. ∗ The algorithm for computing Afix (e), A∗fix (e), Aswap (e), A∗swap (e), R180 (e), and R180 (e), can be described as follows. Algorithm Compute Axial R180 Labels R-node 1. Compute an embedding E of skeleton(v) with e on the outside face; delete e to give an embedding E − of skeleton− (v) with u and w on the outside face. 2. Color u and w with the same colors. 3. Augment E − to make it triconnected, using the star triangulation method described above. 4. Apply the symmetry finding algorithm of [15] and [16] to the augmented colored E − . 5. If the augmented colored E − has an axial planar automorphism αfix that fixes both u and w and respects the isomorphism partition labels and axial labels in skeleton− (v), then Afix (e) := true; else Afix (e) := false.
Drawing Planar Graphs Symmetrically, II
181
6. If the augmented colored E − has an axial planar automorphism αswap that swaps u and w and respects the isomorphism partition labels and axial labels in skeleton− (v), then Aswap (e) := true; else Aswap (e) := false. 7. If the augmented colored E − has a 180◦ rotational planar automorphism β that swaps u and w and respects the isomorphism partition labels and the 180◦ rotation label in skeleton− (v), then R180 (e) := true; else R180 (e) := false. 8. If Afix (e) = false then A∗fix (e) := false; else if either • αfix fixes more than one face, or • αfix swaps the endpoints of a child virtual edge f such that A∗swap ( f ) = true, or • αfix fixes the endpoints of a child virtual edge f such that A∗fix ( f ) = true, then A∗fix (e) := true; else A∗fix (e) := false. 9. If Aswap (e) = false, then A∗swap (e) := false; else if either • αswap fixes more than one face, or • αswap swaps the endpoints of a child virtual edge f such that A∗swap ( f ) = true, or • αswap fixes the endpoints of a child virtual edge f such that A∗fix ( f ) = true, then A∗swap (e) := true; else A∗swap (e) := false. ∗ 10. If R180 (e) = false, then R180 (e) := false; else if either • β fixes more than one face, or ∗ • β fixes a child virtual edge f with R180 ( f ) = true, ∗ ∗ then R180 (e) := true; else R180 (e) := false. LEMMA 6. Compute Axial R180 Labels R-node correctly computes Afix (e), ∗ A∗fix (e), Aswap (e), A∗swap (e), R180 (e), and R180 (e) for R-nodes, in linear time. PROOF. Firstly note that the embedding E − of skeleton− (v), computed at step 1, with u and w on the outside face, is unique. To see this, suppose that there were two different embeddings in which u and w share a face. Re-inserting the edge e would give two different embeddings of skeleton(v), which is a contradiction since skeleton(v) is triconnected. Step 2 ensures that a colored automorphism of the augmented colored E − fixes {u, w}. Thus the symmetry finding algorithm at step 4 only returns automorphisms that either fix u and v, or swap u and v. The correctness of steps 5 and 8 then follows from Lemma 5. Similar arguments can be used to establish the correctness of steps 5, 6, 9 and 10. Now consider the time complexity of the algorithm. Note that when this algorithm is called, the axial labels for each child virtual edge f in skeleton− (v) have already been computed. Steps 1–3 clearly take linear time; in each case, the step calls a linear time algorithm. For steps 5–7, we need to check whether the axial planar automor-
182
S.-H. Hong and P. Eades 111 000 000 111 000 111
111 000 000 111 000 111
f1
f
2
f3
f 4
e
f1
f
f3
2
111 000 000 111 000 111 000 111
(a)
f 4
111 000 000 111 000 111
(b)
Fig. 20. An example of a P-node.
phism computed by the algorithm of [15] and [16] at step 4 fixes various edges and faces. This can be done in linear by using the explicit permutation representation of the automorphism. 5.2. Labeling Algorithms for P-Nodes. This section describes how to compute the labels when v is a P-node. Here we can apply simpler methods than those for R-nodes. The computation of isomorphism partition labels for P-nodes can proceed in precisely the same way as for R-nodes, using very simple algorithms to test isomorphism. We omit the description of these algorithms. Algorithms for axial labels and 180◦ rotation labels are similar to algorithms used to find upward planar automorphisms for series parallel digraphs [14], and we describe them briefly without a great deal of discussion. A P-node and its context are illustrated in Figure 20. Figure 20(a) shows skeleton(v) and it consists of a set of edges in parallel. There are four labeled child virtual edges f 1 , f 2 , f 3 , f 4 , a parent virtual edge e, and one real edge. Figure 20(b) shows skeleton− (v). Any planar automorphism fixes the real edge (if such an edge exists) and maps the child virtual edges among themselves. Note that planarity demands that at most one of the edges (real or virtual) can be fixed. Firstly we describe an algorithm for computing Afix (e) and A∗fix (e) labels for P-nodes. The main idea is to partition the child virtual edges into isomorphism classes, using their isomorphism partition labels. An axial planar automorphism that fixes the separation pair elementwise (so that Afix (e) is true) maps isomorphic child virtual edges to each other. Algorithm Compute Axial Fix Labels P-node 1. Divide the child virtual edges into isomorphism classes, using their isomorphism partition labels. 2. If more than one isomorphism class has odd size, then Afix (e) := A∗fix (e) := false. 3. If all the sizes of the isomorphism classes are even, then (a) Afix (e) := true; (b) if skeleton− (v) has no real edge, then A∗fix (e) := true else A∗fix (e) := false.
Drawing Planar Graphs Symmetrically, II
183
4. If only one isomorphism class has odd size, then if skeleton− (v) has a real edge, then Afix (e) := A∗fix (e) := false else Afix (e) := Afix ( f j ); A∗fix (e) := Afix (e) AND (A∗fix ( f j ) OR A∗swap ( f j )), where f j is a child virtual edge from the isomorphism class with an odd number of elements. Next we describe an algorithm to compute Aswap (e) and A∗swap (e) of a P-node. Algorithm Compute Axial Swap Labels P-node 1. If Aswap ( f i ) = true for every child virtual edge f i , then Aswap (e) := true; else Aswap (e) := false. 2. If Aswap (e) = false then A∗swap (e) := false; else if A∗swap ( f j ) O R A∗fix ( f j ) = true for some child virtual edge f j , then A∗swap (e) := true; else A∗swap (e) := false. ∗ The next algorithm is for the labels R180 (e) and R180 (e) of a P-node. To state this algorithm, we first describe a simple “matching” process. We say that f i reverse matches f j if IP( f i ) is the reverse of IP( f j ). The reverse matching process chooses pairs of child virtual edges that match, until no more reverse matching pairs are left. Now we describe the algorithm.
Algorithm Compute Rotation 180 Labels P-node 1. Perform a reverse matching process on the child virtual edges of skeleton− (v); suppose that is the number of child virtual edges that remain unmatched. ∗ 2. If > 1, then R180 (e) := R180 (e) := false. 3. If = 0, then (a) R180 (e) := true; ∗ ∗ (b) if skeleton− (v) has no real edge, then R180 (e) := true else R180 (e) := false. ∗ 4. If skeleton− (v) has a real edge and = 1, then R180 (e) := R180 (e) := false. − 5. If skeleton (v) has no real edge, and = 1 and f j is the unmatched child ∗ ∗ virtual edge, then R180 (e) := R180 ( f j ); R180 (e) := R180 (e) AND R180 ( f j ). We summarize the results of this section in the following lemma. LEMMA 7. Algorithms Compute Axial Fix Labels P-node, Compute Axial Swap Labels P-node, and Compute Rotation 180 Labels P-node correctly ∗ (e) for P-nodes, in linear compute Afix (e), A∗fix (e), Aswap (e), A∗swap (e), R180 (e), and R180 time.
PROOF. Each of the algorithms clearly runs in linear time. The three algorithms are similar to algorithms for symmetries of parallel compositions in series parallel digraphs [14]. Correctness of Algorithms Compute Axial Fix Labels P-node, Compute Axial Swap Labels P-node, and Compute Rotation 180 Labels P-node
184
S.-H. Hong and P. Eades 111 000 000 111 000 111 00 11 11 00 00 11 00 11
e
f1
00 11 11 00 00 11 00 11
f 00 11 11 00 00 11 00 11
2
f1 11 00 00 11 00 11
00 11 11 00 00 11 00 11 00 11 11 00 00 11
(a)
f
2
11 00 00 11 00 11
(b)
Fig. 21. Example of an S-node.
can be derived in the same way as part (2) of Theorem 2, part (1) of Theorem 3, and part (1) of Theorem 4 in [14] respectively. 5.3. Labeling Algorithms for S-Nodes. In this section we describe the method to compute labels for an S-node. Again the computation of isomorphism partition labels can proceed in precisely the same way as for R-nodes, and we omit the description of these algorithms. Again algorithms for axial labels and 180◦ rotation labels are similar to algorithms used to find upward planar automorphisms for series parallel digraphs [14], and we describe them briefly without a great deal of discussion. An S-node and its context are illustrated in Figure 21. Figure 21(a) shows skeleton(v) and it consists of a cycle consisting of two labeled child virtual edge f 1 , f 2 , a parent virtual edge e, and one real edge. We compute labels on the parent virtual edge from skeleton− (v), which is a simple path, as illustrated in Figure 21(b). First, we describe an algorithm to compute Afix (e) and A∗fix (e). Algorithm Compute Axial Fix Labels S-node 1. If Afix ( f i ) = true, for each child virtual edge f i , then Afix (e) := true; else Afix (e) := false. 2. If Afix (e) = true and there is child virtual edge f j such that either A∗swap ( f j ) or A∗fix ( f j ) is true, then A∗fix (e) := true; else A∗fix (e) := false. Next we explain how to compute Aswap (e) and A∗swap (e) of an S-node. To describe this algorithm, we need to define a string S(e) of integers, which depends on skeleton− (v). Each edge in skeleton− (v) is either real or a child virtual edge. For each edge f , let s( f ) = (−1, −1) if f is a real edge, and let s( f ) be the isomorphism partition label of f if f is a child virtual edge. Note that skeleton− (v) is a path. Form S(e) by concatenating the pairs s( f ) in order that the edge f occurs along the path skeleton− (v). If the path skeleton− (v) has odd length, then the middle edge of skeleton− (v) is the edge that is
Drawing Planar Graphs Symmetrically, II
185
equidistant from the two endpoints of the path. Note that the length of S(e) is twice the length of the path. Now we describe the algorithm. Algorithm Compute Axial Swap Labels S-node 1. Form a string S(e) by s( f ) in order that the edge f occurs along the path skeleton− (v), where s( f ) = (−1, −1) if f is a real edge, or IP( f ) if f is a child virtual edge. 2. If S(e) is not a palindrome, then Aswap (e) := A∗swap (e) := false. 3. If S(e) is a palindrome of length divisible by four, then Aswap (e) := true; A∗swap (e) := false. 4. If S(e) is a palindrome of length equivalent to 2 modulo 4, then • if the middle edge is a real edge, then Aswap (e) := true; A∗swap (e) := false; • if the middle edge is a child virtual edge f j , then Aswap (e) := Aswap ( f j ); A∗swap (e) := Aswap (e) AND (A∗swap ( f j ) O R A∗fix ( f j )). ∗ Finally we explain how to compute R180 (e) and R180 (e) of an S-node. Again, we use the string S(e).
Algorithm Compute Rotation 180 Labels S-node 1. Form a string S(e) by s( f ) in order that the edge f occurs along the path skeleton− (v), where s( f ) = (−1, −1) if f is a real edge, or IP( f ) if f is a child virtual edge. ∗ 2. If S(e) is not a palindrome, then R180 (e) := R180 (e) := false. 3. If S(e) is a palindrome of length divisible by four, then R180 (e) := true; ∗ (e) := false. R180 4. If S(e) is a palindrome of length equivalent to 2 modulo 4, then ∗ • if the middle edge is a real edge, then R180 (e) := true; R180 (e) := false; • if the middle edge is a child virtual edge f j , then R180 (e) := R180 ( f j ); ∗ ∗ R180 := R180 (e) AND R180 ( f j ). We summarize the results of this section in the following lemma. LEMMA 8. Algorithms Compute Axial Fix Labels S-node, Compute Axial Swap Labels S-node, and Compute Rotation 180 Labels S-node correctly ∗ compute Afix (e), A∗fix (e), Aswap (e), A∗swap (e), R180 (e), and R180 (e) for S-nodes, in linear time.
PROOF. The first two algorithms clearly run in linear time. Compute Rotation 180 Labels S-node runs in linear time using a linear time palindrome-checking algorithm. Again, correctness can be established using arguments similar to those for symmetries of series-parallel digraphs. More specifically, Algorithms Compute Axial Fix Labels S-node, Compute Axial Swap Labels S-node and Compute Rotation 180 Labels S-node can be verified to be correct by using part (1) of Theorem 2, part (2) of Theorem 3, and part (2) of Theorem 4 of [14] respectively.
186
S.-H. Hong and P. Eades
6. Computing a Planar Automorphism Group at the Center. The reduction and labeling step (step 2) of Biconnected Planar concludes by labeling the child virtual edges in skeleton(c). The final step of Biconnected Planar is to compute a maximum size planar automorphism group at the center of the SPQR tree. The following lemma summarizes the main result of this section. LEMMA 9. There is a linear time algorithm to compute a maximum size planar automorphism group at the center. The proof of Lemma 9 occupies the remainder of this section. The center of the SPQR tree may be a node or an edge. The case where the center of the SPQR tree is a node is considered in Section 6.1; algorithms for the three different kinds of nodes (R-node, P-node, S-node) are described in the subsections. The case where the center of the SPQR tree is an edge is considered in Section 6.2. 6.1. The Center Is a Node. Suppose that the center (that is, the root) of the SPQR tree is a node c. The labeling algorithms in Sections 5.1–5.3 construct labels on parent virtual edges such that an automorphism ϕ of G is planar if and only if the restriction ϕ of ϕ to skeleton(c) is planar and respects the labels, providing a kind of converse for Lemma 2. The algorithms of Section 5 put isomorphism partition labels, axial labels, and 180◦ rotation labels on the child virtual edges in skeleton(c). Roughly speaking, the aim of this section is to show that if ϕ is a planar automorphism of skeleton(c), then ϕ can be extended to a planar automorphism ϕ of G if and only ϕ respects the isomorphism partition labels, the axial labels, and the 180◦ rotation labels. Then we can compute the maximum size planar automorphism group of G by computing the maximum size planar automorphism group of skeleton(c). Note that skeleton(c) can be an R-node, a P-node, or an S-node; we consider each of these cases in turn in Sections 6.1.1–6.1.3. For each of these cases, the main issue is to deal with the special case of an “enclosing composition”, analogous to that described in Section 4.2. We use the following notation. Let c be the center node and let c1 , c2 , . . . , ck be the children of c, and suppose that e j is the child virtual edge in skeleton(c) corresponding to c j . In an enclosing composition, the separation pair is fixed; thus the size of a planar automorphism group is at most 4, and there are only three possible kinds of non-trivial planar automorphisms: 1. an axial planar automorphism αfix that fixes each endpoint of e j , 2. an axial planar automorphism αswap that swaps the two endpoints of e j , and 3. a 180◦ rotational planar automorphism β180 that swaps the two endpoints of e j . ∗c ∗c We define a boolean label A∗c fix (c j ) (respectively Aswap (c j ) and R180 (c j )), which is true if and only if αfix (respectively αswap and β180 ) exists for an embedding in which skeleton(c) is on an inside face of skeleton(c j ).
6.1.1. The center is an R-node. Suppose that c is an R-node. If skeleton(c) is on the outside face of each skeleton(c j ) where c j is a child of c, then we can simply use the algorithm of [15] and [16], since skeleton(c) is a triconnected simple graph. This algorithm can be used to compute a maximum size planar automorphism group that respects the labels on the child virtual edges.
Drawing Planar Graphs Symmetrically, II
187
However, “enclosing composition” requires special attention. The remainder of this subsection concentrates on the enclosing case. We could test each child c j as a candidate for the enclosing child node and then check the following two conditions: • the graph formed from skeleton(c) by deleting e j has a planar automorphism that fixes the endpoints of e j setwise; and ∗ • the appropriate special label of e j (A∗fix (e j ), A∗swap (e j ), or R180 (e j )) is true. However, a straightforward implementation of these two conditions, for each candidate child c j , would give a quadratic time algorithm. To obtain a linear time algorithm, we need to compute all the labels A∗c fix (c j ), j = 1, 2, . . . , k, in linear time. The following lemma indicates how this might be done. ∗ LEMMA 10. The label A∗c fix (c j ) is true if and only if Afix (e j ) = tr ue, and there is an automorphism α of skeleton(c) that fixes both endpoints of e j and respects the labels on the child virtual edges.
PROOF. If A∗c fix (c j ) is true, then the two conditions can be derived easily. Now suppose that the two conditions hold. From the second condition, using Mani’s theorem [2], [24], skeleton(c) can be drawn as a three-dimensional convex polyhedron that displays α. It is easy to show that α is displayed as a reflection in a plane P. Using a projection from the fixed edge e j to a plane orthogonal to P and parallel to e j , one can obtain a two-dimensional planar drawing D1 of skeleton(c) − {e j } which displays α, in which the child separation pair (that is, the endpoints of e j ) is on the outside face. Since A∗fix (e j ) = true, there is a two-dimensional drawing D2 of G + (c j ) which displays axial symmetry with the parent separation pair fixed and on an inside face F. Combining D1 and D2 shows that A∗c fix (c j ) is true. Lemma 10 can be applied in the following algorithm to compute A∗c fix (c j ): Algorithm Compute A∗c fix R-node 1. Compute the automorphism group of skeleton(c) that respects the isomorphism codes on the child virtual edges. Find a set of at most three generators of the automorphism group. 2. For each automorphism α ∈ of order two: ∗j For each child virtual edge ei for which Afix (ei ) has not been computed for α: if α fixes both endpoints of ei and A∗fix (ei ) is true then for all j such that e j is in the same orbit as ei , A∗c fix (c j ) := true else for all j such that e j is in the same orbit as ei , A∗c fix (c j ) := false. LEMMA 11. Suppose that c is the center R-node and let c1 , c2 , . . . , ck be the children of ∗c c. Compute A∗c fix R-node correctly computes all the labels Afix (c j ), for j = 1, 2, . . . , k, in linear time.
188
S.-H. Hong and P. Eades
PROOF. The first step above takes linear time [4]. The outside loop at step 2 is performed a constant number of times, and the inside loop is performed only a linear number of times (because each A∗c fix (c j ) is computed only once). Thus the algorithm takes linear time. Now we show correctness. From Lemma 10, A∗c fix (c j ) is true if and only if there is an automorphism α of skeleton(c) such that: (i) α has order two and respects the labels on the child virtual edges, and (ii) α fixes both endpoints of e j and A∗fix (e j ) is true. We need to show that in the search for an automorphism satisfying (i) and (ii), we need only consider the generators of the automorphism group. Using Mani’s theorem [2], [24], there is a drawing of skeleton(c) as a convex polyhedron P in three dimensions displaying the whole automorphism group of skeleton(c). We can assume that the group is generated by a set consisting of at most three generators, of which at most two are reflections (see [1]). Now suppose that the automorphism α satisfies properties (i) and (ii) above. It is clear that α is represented as a reflection in P. Furthermore, α is a product of a power of the rotation β ∈ (if such a rotation exists) and a reflection α ∈ . One can deduce that α ∈ fixes a child virtual edge ei in skeleton(c) such that ei is in the same orbit as e j . Thus we only need to check the generators. ∗c Similar algorithms can be used to compute A∗c swap (c j ) and R180 (c j ). Note that to find an enclosing composition with maximum symmetry, we need to ∗c choose a child c j for which as many as possible of the three labels A∗c fix (c j ), Aswap (c j ), ∗c and R180 (c j ) are true.
Algorithm Compute PAG Center R-node 1. Consider the normal composition: use the algorithm of [15] and [16] to compute a maximum size planar automorphism group A of skeleton(c) that respects the isomorphism partition labels, the axial labels, and the 180◦ rotation labels. If A has size 4 or larger, then output the group and stop. 2. Consider the enclosing composition: ∗c (a) For each child c j of the center c, compute A∗c fix (c j ), Aswap (c j ), and ∗c R180 (c j ). (b) For j = 1 to k: ∗c ∗c (i) If all of A∗c fix (c j ), Aswap (c j ) and R180 (c j ) are true, then A j is a dihedral group of size 4. ∗c ∗c (ii) If one of A∗c fix (c j ), Aswap (c j ), and R180 (c j ) are true, then A j has size 2. (iii) Otherwise A j has size 1. 3. Output the maximum size group out of A and A j , j = 1, 2, . . . , k. The correctness of Compute PAG Center R-node follows directly from Lemma 11.
Drawing Planar Graphs Symmetrically, II
(a)
189
(b)
Fig. 22. An example of a center P-node.
6.1.2. The center is a P-node. Figure 22 shows an example when the center is a P-node. Figure 22(a) shows a maximal symmetric drawing of the graph and Figure 22(b) shows the SPQR tree of the graph. As with R-node centers, the case when skeleton(c) is on the outside face of skeleton(c j ) for each child c j of c is straightforward, and the enclosing case, where skeleton(c) is on an inside face of some skeleton(c j ), is more complex. First we deal with the standard case, where skeleton(c) is on the outside face of skeleton(c j ) for each child c j of c. Note that the size of a planar automorphism group is at most 4, and there are only three possible kinds of non-trivial planar automorphisms: 1. an axial planar automorphism αfix that fixes both endpoints of skeleton(c), 2. an axial planar automorphism αswap that swaps the endpoints of skeleton(c), and 3. a 180◦ rotational planar automorphism β180 that swaps the endpoints of skeleton(c). We define a boolean label Afix (c) (respectively Aswap (c) and R180 (c)), which is true if and only if αfix (respectively αswap and β180 ) exists. To find these automorphisms, we can use variations of the labeling algorithms for computing Afix , Aswap , and R180 for P-nodes, as presented in Section 5.2. The essential difference is that, for the center c, the algorithms operate on skeleton(c), because skeleton− (c) is not defined. We omit these algorithms. Now consider the enclosing case. We use the following algorithm to compute A∗c fix (c j ). This algorithm assumes that we have already computed Afix (c), using the algorithm in Section 5.2 (substituting skeleton(c) for skeleton− (v)). Note that this algorithm computes the sizes of the isomorphism classes of the child virtual edges. Algorithm Compute A∗c fix P-node 1. For each child virtual edge c j , initialize the value of A∗c fix (c j ) to false. 2. If there is an axial planar automorphism αfix that fixes both endpoints of skeleton(c) (that is, if Afix (c) = true): (a) then If αfix fixes a child virtual edge c j , (i) then if A∗fix (e j ) = true, then A∗c fix (c j ) := true. (ii) else for each child virtual edge c j with A∗fix (e j ) = true: A∗c fix (c j ) := true.
190
S.-H. Hong and P. Eades
(b) else If there are only two odd size isomorphism classes I and J of the child virtual edges, then suppose that ci ∈ I and c j ∈ J ; if Afix (ei ) = true and A∗fix (e j ) = true, then A∗c fix (c j ) := true; if Afix (e j ) = true and A∗fix (ei ) = true, then A∗c fix (ci ) := true. LEMMA 12.
∗c Compute A∗c fix P-node correctly computes all Afix (c j ) in linear time.
PROOF. Suppose that the isomorphism classes of the edges of skeleton(c) are I1 , I2 , . . . , I . For each ei that is not fixed by the axial planar automorphism, there is an ei that “matches” ei , that is, ei and ei are in the same isomorphism class. Thus if F is the set of edges fixed by α, then |I j − F| is even for each j. Further, 1 ≤ |F| ≤ 2 (since the enclosing child must be fixed, and there is at most one fixed child that is not enclosing). Step 2(a)(i) covers the case when |F| = 1, and |I j | is odd for exactly one j. Step 2(a)(ii) covers the case where |F| = 2, and all |I j | are even. Step 2(b) covers the case where |F| = 2, and exactly two of the |I j | are odd. ∗c One can compute A∗c swap (c j ) and R180 (c j ) with similar algorithms. Figure 23(b) shows an example of the enclosing composition of a center P-node which displays more symmetries than the drawing in Figure 23(a). Figure 23(c) shows the SPQR tree of the graph. Some care is needed to compute the maximum size planar automorphism group from Afix (c), Aswap (c), and R180 (c), because, for example, it may be possible either to display αfix as in Figure 24(a) or β180 as in Figure 24(b), but not both in the same drawing. Again, it may be possible either to display αswap as in Figure 25(a) or β180 as in Figure 25(b), but not both in the same drawing. This is very similar to the situation for series parallel digraphs; see [14]. Here we state the algorithm without proof:
(a)
(b)
Fig. 23. An example of the enclosing composition of a center P-node.
(c)
Drawing Planar Graphs Symmetrically, II
191
(a)
(b)
Fig. 24. Display of (a) αfix and (b) β180 .
Algorithm Compute PAG Center P-node 1. Consider the normal composition: (a) Compute the labels Afix (c), Aswap (c), and R180 (c). (b) Compute the maximum size m of a planar automorphism group without an enclosing composition as follows: (i) If Afix (c) = Aswap (c) = R180 (c) = false, then m = 1. (ii) If precisely one of Afix (c), Aswap (c), and R180 (c) is true, then m = 2. (iii) If Aswap (c) = R180 (c) = true but Afix = false, then m = 2. (iv) If Afix (c) = R180 (c) = true but Aswap = false, then m = 2. (v) If Afix (c) = Aswap (c) = true, then m = 4. 2. Consider the enclosing composition: ∗ (a) Compute the labels A∗fix (c), A∗swap (c), and R180 (c). ∗ (b) Compute the maximum size m of a planar automorphism group with an enclosing composition as follows: ∗ (i) If A∗fix (c) = A∗swap (c) = R180 (c) = false, then m ∗ = 1. ∗ ∗ (c) is true, then (ii) If precisely one of Afix (c), A∗swap (c), and R180 ∗ m = 2. ∗ (iii) If A∗swap (c) = R180 (c) = true but A∗fix = false, then m ∗ = 2. ∗ ∗ (iv) If Afix (c) = R180 (c) = true but A∗swap = false, then m ∗ = 2. (v) If A∗fix (c) = A∗swap (c) = true, then m ∗ = 4. 3. Output the maximum out of m and m ∗ .
(a)
(b)
Fig. 25. Display of (a) αswap and (b) β180 .
192
S.-H. Hong and P. Eades
(a)
(b) Fig. 26. An example of the center S-node.
LEMMA 13. Compute PAG Center P-node correctly computes the maximum planar automorphism group in linear time. PROOF. The conditions at step 2 are very similar to the case of parallel compositions of series parallel digraphs; see Theorem 5 of [14]. 6.1.3. The center is an S-node. If c is an S-node, then we can use string matching methods, as with the algorithms for computing labels for S-nodes in Section 5.3. Figure 26 shows an example when the center is an S-node. Figure 26(a) shows a maximal symmetric drawing of the graph and Figure 26(b) shows the SPQR tree of the graph. Again the algorithms must operate on skeleton(c) rather than skeleton− (c) (which is undefined). This implies that the string matching methods are now applied to circular strings, and so we must use different algorithms. As in Section 5.3, for each edge e of skeleton(c) we define s(e) = (−1, −1) if e is a real edge, and s(e) = IP(e) if e is a child virtual edge. Denote the concatenation of the pairs s(e) in order around the cycle of the skeleton(c) by S(c). We consider S(c) to be a circular string. When skeleton(ci ) is on the outside face of skeleton(c) for each child ci of c, the algorithm uses this circular string to determine maximum size planar automorphism groups. This method is essentially the same as that used by Manning and Atallah [27] to find planar automorphisms of outerplanar graphs, and we omit details. The enclosing case is more complex. Computing A∗c fix (c j ) is straightforward because ∗c Afix (c j ) cannot be true unless Afix (ci ) = true for all children ci of c; further, if Afix (ci ) = ∗j true for all children ci of c, then Afix (c) = A∗fix (e j ) for each child c j . Computing A∗c swap (c j ) is also very simple, because αswap exists for an enclosing embedding if and only if it exists for an embedding in which skeleton(c) is on an inside face of skeleton(c j ). Computing ∗c ∗c R180 (c j ) is a little more complex. Note that R180 (c j ) = true if and only if for some c j : 1. the circular string S(e) has an automorphism β of order two that fixes e j , ∗ (e j ) = true, and 2. R180 3. for each child virtual edge ei fixed by β, R180 (ei ) = true.
Drawing Planar Graphs Symmetrically, II
193
Thus we use the following algorithm; it uses a generating set of the automorphism group, in a similar approach to Compute A∗c fix R-node. Here the group is simpler: it is just the automorphism group of a labeled circular string. ∗c Algorithm Compute R180 S-node
1. Compute a set of at most two generators for the automorphism group of the circular string S(e). 2. If contains an automorphism β of order two, then ∗c For each child virtual edge ei for which R180 (c j ) has not been computed: Compute the set F of child virtual edges which are fixed by β. ∗ If R180 (ei ) = true for all ei ∈ F, and R180 (ei ) = true for some ei ∈ F: then for all j such that e j is in the same orbit as ei , A∗c fix (c j ) := true else for all j such that e j is in the same orbit as ei , A∗c fix (c j ) := false. LEMMA 14.
∗c ∗c S-node correctly computes all R180 (c j ) in linear time. Compute R180
PROOF. The group of the circular string is, at worst, dihedral, and the generating set can be computed in linear time using standard string matching methods. Extending from the generating set to the other automorphisms can be justified in the same way as in Lemma 11. Figure 27(b) shows an example of the enclosing composition of a center S-node which displays more symmetry than the drawing in Figure 27(a). Figure 27(c) shows the SPQR tree of the graph. Finally we state the algorithm for computing the maximum planar automorphism group when the center is an S-node; its correctness and linear time complexity is clear. Algorithm Compute PAG Center S-node 1. First consider the standard case: use the algorithm of Manning and Atallah [27] to compute a maximum size planar automorphism group A.
(a)
(b)
(c)
Fig. 27. An example of the enclosing composition of a center S-node.
194
S.-H. Hong and P. Eades 1 0 0 1 0 1
11 00 00 11 00 11
11 00 00 11
e
e
1 0 1 0
11 00 00 11
a
b
e
e 11 00 00 11 00 11
(b)
(a)
Fig. 28. Examples of center edge and parallel composition.
2. Next consider the enclosing case: ∗c ∗c (a) Compute A∗c fix (c j ) , Aswap (c j ), and R180 (c j ). ∗c ∗c ∗c (b) If more than one of Afix (c j ) , Aswap (c j ), and R180 (c j ) is true for some j, then compute a dihedral planar automorphism group A j of size 4. ∗c ∗c (c) If exactly one of A∗c fix (c j ) , Aswap (c j ), and R180 (c j ) is true for some j, then compute a planar automorphism group A j of size 2. 3. Output the largest of A and the A j . 6.2. The Center Is an Edge. Now we describe the case when the center of the SPQR tree is an edge η. The separation pair represented by η must be fixed setwise by the automorphism. Thus, the size of a planar automorphism group is at most 4. Suppose that a and b are the two child nodes incident to η as in Figure 28(a). Then we can construct a drawing of G in two ways: 1. Parallel composition: We make a center node c such that skeleton(c) consists of two virtual edges e, each labeled from skeleton− (a) and skeleton− (b). Then we compute the maximum size planar automorphism group using the same method as for the case where the center node is a P-node. Figure 28(b) shows an example. 2. Treat one node as the parent of the other: In this case we compute maximum size planar automorphism group at the parent node using the method described in Section 6.1. Concrete examples are illustrated in Figures 29–31. Figure 29(a) shows the SPQR tree of a graph and Figure 29(b) shows a drawing constructed by parallel composition. Figure 29(c) shows a drawing constructed by taking a as the parent of b. In this case the parallel composition displays more symmetry.
1 0 0 1 1 0 1 0
1 0 1 0
1 0 1 0
e 1 0 1 0
1 0 1 0
1 0 1 0 1 0 1 0
1 0 1 0
(a)
e 1 0 1 0
111 000 000 111 000 111
00 11 11 00 00 11 00 11 00 11 11 00 00 11 0011 11 00 11 00 00 00 11 11 00 0011 11
111 000 000 111 000 111
000 111 11 00 000 111 00 11 000 111 000 111 00 11 000 111 000 111 00 11 000 111
00 11 11 00 00 11
(b)
Fig. 29. Examples of compositions.
111 000 000 111 000 111
00 11 11 00 00 11 00 11 00 11 00 11 00 11 00 11 00 11 00 11 00 11 00 11 00 11 00 11
(c)
11 00 00 11 00 11
Drawing Planar Graphs Symmetrically, II
195 1 0 1 0
1 0 0 1 1 0 0 1
1 0 0 1
1 0 0 1
e 1 0 0 1
1 0 0 1
e 1 0 1 0
1 0 0 1
a
11 00 00 11 00 11
1 0 1 0 1 0 0 1
1 0 1 0
1 0 1 0
1 0 1 0
1 0 1 0
1 0 1 0
00 11 11 00 00 11
1 0 0 1 11 00 00 11
1 0 0 1
1 0 0 1
1 0 1 0
1 0 0 1 0 1
1 0 0 1
1 0 0 1
00 11 11 00 00 11 00 11 00 11 00 11
00 11 11 00 00 11
11 00 00 11
b (b)
(a)
(c)
(d)
Fig. 30. Examples of compositions.
Figure 30(a) shows the SPQR tree of a graph and Figure 30(b) shows a drawing constructed by parallel composition. Figure 30(c) shows a drawing constructed by taking a as the parent of b and Figure 31(d) shows a drawing constructed by taking b as the parent of a. In this case, taking a as the parent of b displays more symmetry. Figure 31(a) shows the SPQR tree of a graph and Figure 31(b) shows a drawing constructed by parallel composition. Figure 31(c) shows a drawing constructed by taking a as the parent of b and Figure 31(d) shows a drawing constructed by an enclosing composition. In this case the enclosing composition displays more symmetry. Thus the algorithm can be described as follows: Algorithm Compute PAG Center Edge 1. Compute a maximum size planar automorphism group with a parallel composition. 2. Compute a maximum size planar automorphism group with a as the center node. 3. Compute a maximum size planar automorphism group with b as the center node. 4. Find the maximum between 1, 2, and 3. 7. The Drawing Algorithm. The algorithm presented in the preceding sections takes a biconnected planar graph as input and has two outputs: a planar automorphism group of maximum size, and an embedding of the graph. In this section we show how use this information to construct a straight-line symmetric drawing of the graph.
a
b
(a)
(b)
Fig. 31. Examples of compositions.
(c)
(d)
196
S.-H. Hong and P. Eades
Given an embedding of a biconnected planar graph, we use “augmentation”: we increase the connectivity by adding new edges and new vertices to make it triconnected, while preserving the planar automorphism group. This can be done using the method in Section 5.1.2; see Figure 19. Then we can apply the algorithm for constructing symmetric drawings of triconnected planar graphs with straight-line edges to construct a symmetric drawing [15], [16]. This algorithm runs in linear time [15], [16]. Finally we delete the added edges and vertices. The following theorem summarizes the result of this section. THEOREM 3. There is a linear time algorithm to draw a biconnected graph to display a maximum size symmetry group. The drawing has straight-line edges.
8. Proof of Theorem 1. Here we summarize the proof of Theorem 1. The first step of Biconnected Planar correctly computes the rooted SPQR tree using the linear time algorithm of [6]. The reduction and labeling step uses the algorithms of Section 5. Lemmas 4–8 guarantee that, at the end of this step, the labels are correct. Lemma 2 implies if ϕ is a planar automorphism group of the input graph, then the restriction of ϕ to the center of the SPQR tree is a planar automorphism. The correctness of the labeling algorithms implies that a planar automorphism at the center can be extended to a planar automorphism of the input graph. The correctness of the algorithms of Section 6 then imply Theorem 2. Together with Theorem 3, this implies Theorem 1.
9. Conclusion. In this paper we present a linear time algorithm for finding the maximum size planar automorphism group of a biconnected planar graph. This algorithm shows that the planar automorphism problem for biconnected planar graphs can be solved in linear time, in contrast to the more general problem. We also describe a simple linear time drawing algorithm. The next paper in this series describes algorithms for drawing one-connected planar graphs as symmetrically as possible; see [11]. References [1] [2]
M. A. Armstrong, Groups and Symmetry, Springer-Verlag, New York, 1988. L. Babai, Automorphism Groups, Isomorphism, and Reconstruction, in Handbook of Combinatorics, Volume 2 (R. L. Graham, M. Groetschel, and L. Lovasz, eds.), Chapter 27, Elsevier, Amsterdam, 1995. [3] C. Buchheim and M. Junger, Detecting Symmetries by Branch and Cut, Graph Drawing 2001, Lecture Notes in Computer Science 2265, pp. 178–188, Springer-Verlag, Berlin, 2002. [4] C. J. Colburn and K. S. Booth, Linear Time Automorphism Algorithms for Trees, Interval Graphs, and Planar Graphs, SIAM Journal on Computing 10(1), 203–225, 1981. [5] G. di Battista, P. Eades, R. Tamassia and I. G. Tollis, Graph Drawing: Algorithms for the Visualization of Graphs, Prentice-Hall, Englewood Cliffs, NJ, 1998. [6] G. di Battista and R. Tamassia, On-Line Planarity Testing, SIAM Journal on Computing 25(5), 956–997, 1996.
Drawing Planar Graphs Symmetrically, II [7] [8] [9] [10] [11] [12] [13]
[14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25] [26] [27] [28] [29] [30]
197
P. Eades and X. Lin, Spring Algorithms and Symmetries, Theoretical Computer Science 240, 379–405, 2000. M. Fontet, Linear Algorithms for Testing Isomorphism of Planar Graphs, Proceedings of the Third Colloquium on Automata, Languages and Programming, pp. 411–423, 1976. H. de Fraysseix, An Heuristic for Graph Symmetry Detection, Graph Drawing 99, Lecture Notes in Computer Science 1731, pp. 276–285, Springer-Verlag, Berlin, 2000. S. Hong, Algorithms for Maximum Symmetry Detection and Symmetric Drawings for Planar Graphs, Ph.D. Thesis, Ewha University, 1999. S. Hong and P. Eades, Drawing Planar Graphs Symmetrically, III: One-Connected Graphs, Algorithmica (to appear). S. Hong and P. Eades, Symmetric Layout of Disconnected Graphs, Algorithms and Computation (Proc. of ISAAC 2003), Lecture Notes in Computer Science 2906, pp. 405–414, Springer-Verlag, Berlin, 2003. S. Hong, P. Eades and S. Lee, An Algorithm for Finding Geometric Automorphisms in Planar Graphs, Algorithms and Computation (Proc. of ISAAC 98), Lecture Notes in Computer Science 1533, pp. 277– 286, Springer-Verlag, Berlin, 1998. S. Hong, P. Eades and S. Lee, Drawing Series Parallel Digraphs Symmetrically, Computational Geometry: Theory and Applicatons 17(3–4), 165–188, 2000. S. Hong, B. McKay and P. Eades, Symmetric Drawings of Triconnected Planar Graphs, Proceedings of SODA 2002, pp. 356–365, 2002. S. Hong, B. McKay and P. Eades, A Linear Time Algorithm for Constructing Maximally Symmetric Drawings of Triconnected Planar Graphs, Discrete & Computational Geometry (to appear). J. E. Hopcroft and R. E. Tarjan, A V 2 Algorithm for Determining Isomorphism of Planar Graphs, Information Processing Letters 1(1), 32–34, 1971. J. E. Hopcroft and R. E. Tarjan, A V log V Algorithm for Isomorphism of Triconnected Planar Graphs, Journal of Computer and System Sciences 7, 323–331, 1971. J. E. Hopcroft and R. E. Tarjan, Isomorphism of Planar Graphs, in Complexity of Computer Computations (R. E. Miller and J. W. Thatcher, eds.), Plenum, New York, pp. 131–151, 1972. J. E. Hopcroft and R. E. Tarjan, Dividing a Graph into Triconnected Components, SIAM Journal on Computing 2, 135–158, 1973. J. E. Hopcroft and J. K. Wong, Linear Time Algorithm for Isomorphism of Planar Graphs, Proceedings of the Sixth Annual ACM Symposium on Theory of Computing, pp. 172–184, 1974. R. J. Lipton, S. C. North and J. S. Sandberg, A Method for Drawing Graphs, Proceedings of ACM Symposium on Computational Geometry, pp. 153–160, ACM, New York, 1985. A. Lubiw, Some NP-Complete Problems Similar to Graph Isomorphism, SIAM Journal on Computing 10(1), 11–21, 1981. P. Mani, Automorphismen von Polyedrischen Graphen, Mathematische Annalen 192, 279–303, 1971. J. Manning, Geometric Symmetry in Graphs, Ph.D. Thesis, Purdue University, 1990. J. Manning and M. J. Atallah, Fast Detection and Display of Symmetry in Trees, Congressus Numerantium 64, 159–169, 1988. J. Manning and M. J. Atallah, Fast Detection and Display of Symmetry in Outerplanar Graphs, Discrete Applied Mathematics 39, 13–35, 1992. R. Mathon, A Note on Graph Isomorphism Counting Problem, Information Processing Letters 8, 131– 132, 1979. W. T. Tutte, Graph Theory, Encyclopedia of Mathematics and Its Applications, Vol. 21, Addison-Wesley, Reading, MA, 1984. H. Wielandt, Finite Permutation Groups, Academic Press, New York, 1964.