Genus distributions of cubic series-parallel graphs

We derive a quadratic-time algorithm for the genus distribution of any 3-regular, biconnected series-parallel graph, which we extend to any biconnected series-parallel graph of maximum degree at most 3. Since the biconnected components of every graph of treewidth 2 are series-parallel graphs, this yields, by use of bar-amalgamation, a quadratic-time algorithm for every graph of treewidth at most 2 and maximum degree at most 3.


Introduction
For i = 0, 1, 2, . .., let g i (G) be the number of topologically distinct cellular embeddings of the graph G in the orientable surface S i of genus i.The genus distribution of the graph G is the sequence of numbers g i (G) : i = 0, 1, . . . (1) By the interpolation principle (see Theorem 3.4.1 of [GrTu87] or Theorem 4.5.3 of [MoTh01]), the set {i : g i (G) > 0} is a set of consecutive integers.The smallest number in this set is the minimum genus of the graph G, and the largest is the maximum genus of G.
The main focus of this paper is the derivation of a quadratic-time algorithm for the genus distribution of any 3-regular, biconnected series-parallel graph.This algorithm is readily extended to a quadratic-time algorithm for the genus distribution of any graph of treewidth at most 2 and maximum degree at most 3.The simplicity with which this specialized algorithm can be implemented, or applied by hand with the aid of a spreadsheet, distinguishes it from the recently derived quadratic-time algorithm [Gr14] for the genus distribution of any class of graphs of fixed treewidth and bounded degree.
Thanks to Maria Chudnovsky for suggesting series-parallel graphs as an interesting family of lowtreewidth graphs for a genus distribution calculation.

Basic results on genus distribution
Five fundamental papers [GKP10, Gr11a, PKG10, KPG10, PKG12] of the first author and his co-authors Khan and Poshni have established methods for calculating the genus distribution of a graph that is constructed by various kinds of amalgamation of graphs of known genus distribution.These methods involve partitioned genus distributions and productions.In order to develop an algorithm for a specific class of graphs, the starting point is to formulate a recursive specification of the graphs in that class, in which the operations used to create larger graphs from smaller graphs are varieties of amalgamation or selfamalgamation.Then methods similar to those of the five fundamental papers are used to calculate the genus distribution recursively.This paradigm was used successfully in calculating the genus distributions of 3-regular outerplanar graphs [Gr11b], of 4-regular outerplanar graphs [PKG11], of Halin graphs [Gr13], and of the 3 × n-mesh graphs [KPG12].We adopt the same paradigm in this paper.

Connections of treewidth to embedding problems
Since the introduction of the concept of treewidth by Robertson and Seymour, bounding the treewidth has been widely used to obtain polynomial-time algorithms for problems that are otherwise NP-hard.In particular, deciding whether an arbitrarily selected graph can be embedded in a given surface is NPcomplete [Th89]; however, for any class of graphs of bounded treewidth, Kawarabayashi, Mohar, and Reed [KMR09] have derived a linear-time algorithm for calculating the minimum genus.
Although outerplanar graphs have treewidth 2, and although Halin graphs and P 3 × P n meshes have treewidth 3 (see [Bo98]), decomposition trees have not occurred in the calculation of specific genus distributions in any papers as yet.Nonetheless, low treewidth plays an implicit role in the recursive specification of the family of graphs in each of those papers.Similarly, in the present paper, low treewidth plays an implicit role, since it allows for a simple recursive construction of the graphs under consideration.

Terminology
In what follows, a graph is taken to be connected and devoid of self-loops, unless something else can be inferred from the immediate context.Multi-edges are to be expected.We use V G and E G to denote the vertex set and edge set of a graph G.A connected graph is biconnected if it has no cutpoints.
The embeddings in this paper are cellular embeddings in oriented surfaces.The terminology used here is predominantly consistent with [GrTu87] and [BWGT09].See also [MoTh01], for a slightly different approach.We abbreviate "face-boundary walk" as fb-walk.
A two-terminal series-parallel graph is a doubly vertex-rooted graph (G, p, q), as per the following recursive definition.
B The graph (K 2 , p, q) is a two-terminal series-parallel graph, where p and q are the vertices of K 2 , called the source root and the target root, respectively.
R 1 series operation (G, p, q) s (G , p , q ) Target root q of G is merged with source root p of G .The amalgamated graph G s G with roots p and q , as in Figure 1(a), is a two-terminal series-parallel graph.
R 2 parallel operation (G, p, q) p (G , p , q ) The result of merging source root p with source root p , and also merging target root q with target root q , as in Figure 1(b), is a two-terminal series-parallel graph.
p' q' q p s q' p p' q' q q t p p p (a) (b) Fig. 1: Operations on series-parallel graphs.
A graph G is a series-parallel graph if there is a choice of terminals p and q such that (G, p, q) is a twoterminal series-parallel graph.Our definition here is consistent with that of [Bo98] and [Ep92].A third operation, called a jackknife operation is allowed by [BPT09], and the resulting class of graphs that they call "series-parallel" is equivalent to that of [Du65] -see Remark 8.1 of [BPT09].The "series-parallel graphs" in [Du65] are identified there as the graphs with no embedded "Wheatstone bridge" (which is Duffin's terminology for a K 4 topological minor).These are precisely the graphs that have no K 4 -minor (e.g., see Proposition 1.7.2 of [Die06]).According to Theorem 17 of [Bo98], the graphs without a K 4minor are exactly the graphs of treewidth at most 2. It follows that our extended genus-distribution algorithm can be applied to any of them in quadratic time, and that we do not need to further explore the distinctions between the varying definitions of "series-parallel graphs".

Outline of this paper
Section 2 derives a characterization of 3-regular, biconnected series-parallel graphs that facilitates the genus distribution algorithm for that family of graphs.Section 3 introduces the concepts of partitioned genus distributions and productions.The top-level description of an algorithm for the genus distribution of any 3-regular, biconnected series-parallel graph is given in Section 4. Sections 5 and 6 derive the productions needed to complete the calculation, as well as their application to calculating the genus distribution of an illustrative example.Section 6 also gives proof that the algorithm runs in quadratic time.Section 7 extends the algorithm to all graphs of treewidth 2 and maximum degree 3.This paper is almost entirely self-contained, except for some details of the well-established concept of partitioned genus distributions and of the methods (as in [GKP10] and [PKG10]) for constructing productions (which are quite necessary for the algorithm).Prior experience with calculating genus distributions of graph amalgamations, especially as in [Gr11b] and [Gr13], is likely to be quite helpful.

Cubic Biconnected Series-Parallel Graphs
The dipole D n is the graph with two vertices and an n-fold multi-edge joining them.In this section, we prove that every 3-regular, biconnected series-parallel graph can be obtained by iterated application of the following operation to the dipole D 3 .
τ Trisect an arbitrary edge e of a graph G and install a new edge in parallel to the "middle third" of edge e.
This operation, which is applicable to an non-empty graph, is called a dmt-step ("dmt" is an abbreviation of "double the middle third"), is illustrated by Figure 2. We define a second operation τ −1 , which is applicable to 3-regular multigraphs, other than the dipole D 3 .We observe that the operation τ −1 can be used as an inverse to the operation τ .τ −1 In a 3-regular graph G, let d and e be edges that share the same two endpoints, u and v, and in which no other edge shares these two endpoints.Delete edge d, and then smooth away vertices u and v.
The proof of our characterization of 3-regular, biconnected series-parallel graphs uses the following four propositions.
Proposition 2.1 (Theorem 42 of [Bo98]) A graph G has treewidth at most 2 if and only if every biconnected component of G is a series-parallel graph.
Proposition 2.2 A graph G has treewidth at most 2 if and only if contains no K 4 -minor.
Proof: This follows immediately from Theorem 17 of [Bo98]. 2 Proposition 2.3 Let G be a 3-regular, biconnected series-parallel graph, and let G be a graph with at least two vertices, obtained by applying operation τ −1 to edges d and e of G , with shared endpoints u and v. Then G is 3-regular, biconnected, and series-parallel.
Proof: Since G is 3-regular, all of its vertices are 3-valent.The operation τ −1 eliminates two vertices of G without changing the valences of the remaining vertices.Thus, the graph G is 3-regular.Let x and y be any two vertices of G .Since G is biconnected, there is a pair of internally disjoint paths in G joining x and y, by Menger's theorem.If one of these paths contains either of the vertices u or v, then it also contains one of the edges d or e, since G is 3-regular, and the other path contains neither vertex u nor vertex v. Thus the images of the two internally disjoint path in G are two internally disjoint paths in G .Hence, the graph G is biconnected.
Since the graph G is series-parallel, its treewidth is at most 2, by Proposition 2.1.It follows from Proposition 2.2 that G has no K 4 -minor.Accordingly, the graph G has no K 4 minor.Therefore, by Proposition 2.2, the graph G has treewidth at most 2. We conclude from Proposition 2.1 that the graph G is series-parallel.2 Proposition 2.4 (Dirac's theorem, [Dir52]) Let G be a biconnected simple graph of minimum degree 3. Then G contains a subgraph that is homeomorphic to the complete graph K 4 .
Theorem 2.5 Let G be a biconnected 3-regular series-parallel graph.Then there exist vertices p, q ∈ V G such that the two-terminal series-parallel graph (G, p, q) is derivable from (D 3 , p, q) by a sequence of applications of the operation τ .
Proof: Let H be a smallest graph obtainable by iterative application of operation τ −1 to the graph G, that is, a graph such that no pair of vertices is joined by exactly two edges.By Proposition 2.3, the graph H is 3-regular, biconnected, and series-parallel.We observe that H cannot be simple, lest it contain, by Dirac's theorem, a homeomorphic copy of K 4 , a contradiction, in view of Propositions 2.2 and 2.1.Accordingly, there is a pair of vertices p, q ∈ V H with at least two edges joining them.Since there cannot be exactly two edges joining p and q, by the minimality of the graph H, and since H is 3-regular, it follows that H ∼ = D 3 .Reversing the sequence of τ −1 -operations, we obtain a derivation of (G, p, q) from (D 3 , p, q) by iterative application of the operation τ . 2 We define a dmt-string to be a graph obtained by iterative application of dmt-steps to the graph K 2 .We observe that each dmt-string has two univalent vertices and that all other vertices are trivalent.
Corollary 2.6 Let (G, p, q) be a 3-regular, biconnected two-terminal series-parallel graph.Then (G, p, q) can be represented by a set of three dmt-strings, each with a univalent p-vertex and a univalent q-vertex, from which (G, p, q) is formed by two parallel operations.

Partials and Productions
When calculating the genus distribution of a family of graphs, we commonly use a finer partition of the embeddings during the intermediate steps.For computational purposes, we need to isolate subsets of embeddings upon which the surgical operations used in the recursive construction of that family have the same effect.Whereas the genus distribution of a graph is an inventory according only (as per (1)) to the genus of the embedding surface, a partitioned genus distribution refines the genus distribution of a rooted graph, according to the incidence of fb-walks on the roots, which is the critical factor in the behavior of a surgical operation on an embedding.In other words, a partitioned genus distribution is a partition of all embeddings of the graph with a given genus into into several types, which allows us to keep under control the structure of the faces incident with the roots before, respectively after the amalgamation.The cells of the finer partition are called partials.In this context, we sometimes abbreviate genus distribution as gd and partitioned genus distribution as pgd.
Calculating the genus distributions of 3-regular series-parallel graphs involves amalgamating subgraphs at pairs of terminals, such that the sum of the degrees of an amalgamated pair of vertices is at most 3. Thus, the possible degrees of the terminals prior to the final operation are 1 and 2. When both terminals are univalent, the genus distribution of (G, p, q) is partitioned into the following partials: = the number of embeddings G → S i such that terminals p and q do not occur on the same fb-walk; uu i (G, p, q) = the number of embeddings G → S i such that terminals p and q occur on the same fb-walk.
The letter u in the name of the partial is a mnemonic for univalent.For every i = 0, 1, 2, . .., the set of all embeddings of (G, p, q) with genus i gives a partitioned genus distribution given by the formula When terminal p is univalent and terminal q is bivalent, the letters d or s in the name of the partial mean, respectively, that q occurs on two different fb-walks or that q occurs twice on the same fb-walk.
There are four partials: = the number of embeddings G → S i such that terminal p occurs on neither fb-walk incident at q; ud i (G, p, q) = the number of embeddings G → S i such that terminal p occurs on one fb-walk incident at q; us • i (G, p, q) = the number of embeddings G → S i such that terminal p does not occur on the fb-walk incident at q; us i (G, p, q) = the number of embeddings G → S i such that terminal p occurs on the fb-walk incident at q.
As before, for every i = 0, 1, 2, . .., the set of all embeddings of (G, p, q) with genus i has a partitioned genus distribution according to the formula Similarly, when p is bivalent and q is univalent, there are four partials: = the number of embeddings G → S i such that terminal q occurs on neither fb-walk incident at p; du i (G, p, q) = the number of embeddings G → S i such that terminal q occurs on one fb-walk incident at p; su • i (G, p, q) = the number of embeddings G → S i such that terminal q does not occur on the fb-walk incident at p; su i (G, p, q) = the number of embeddings G → S i such that terminal q occurs on the fb-walk incident at p.
Suppose that p 1 , p 2 , . . ., p s is a set of partials for a genus distribution.A production for a given surgical operation that transforms a graph embedding X → S i (or a tuple of graph embeddings) into a set of graph embeddings of the graph Y is an algebraic rule of this form: The left side is called the antecedent, and the right side is called the consequent.The meaning is that the operation transforms a single embedding of graph X of type p j on the orientable surface S i of genus i into a set of embeddings of the graph Y , of which c k are of type p k on the surface S f j k (i) , for each i, j, and k.A drawing is usually used as an aid in deriving the production and in proving its correctness.The names of the graphs and their roots can be suppressed when there is in context no ambiguity.Thus, we may write In general, when there are n partials, a surgical operation on two graphs is represented by n 2 productions for the partials.It is clear to someone familiar with the use of partials and productions that it is possible to represent the parallel operation and the series operation by respective lists of productions, one for each ordered pair of partials.This would also lead to an algorithm that requires quadratic-time.Since our present objective is an algorithm that can be described concisely and calculated by hand for small graphs, we intend here to construct shorter lists of productions.

An Algorithm
Our Algorithm 4.1 for calculating the genus distribution of any cubic, biconnected, two-terminal seriesparallel graph G has five steps.Algorithm 4.1 Genus distribution algorithm for a cubic, biconnected, series-parallel graph G.
Input: A 3-regular biconnected series-parallel graph G. Output: The genus distribution of the graph G.
1. Choose the endpoints p and q of an edge as the terminals.
2. Determine the three dmt-strings N 1 , N 2 , N 3 corresponding to the graph (G, p, q). 3. Calculate the pgd of each of the three dmt-strings N 1 , N 2 , N 3 .4. Calculate the pgd of the graph N 1 p N 2 .5. Calculate the gd of the graph G = (N 1 p N 2 ) p N 3 .
Step (1).Lemma 9 of [Ep92] shows that a biconnected series-parallel graph is two-terminal seriesparallel, for any pair of terminals p and q that are joined by an edge.Therefore, we can select as terminals p and q the endpoints of any edge of G.
Step (2).Determine the three dmt-strings (N 1 , p, q), (N 2 , p, q), (N 3 , p, q) for the graph G, by splitting both of the vertices p and q of the dipole D 3 into three vertices, each an endpoint of one of the edges incident on the split vertex.
Step (3).It simplifies this calculation if we define a small modification of the parallel operation p .When we combine two dmt-strings with a parallel operation, we obtain two 2-valent vertices.Our modified operation p attaches a spike at each of these 2-valent vertices, as illustrated in Figure 3, so that we once again have a dmt-string.Similarly, our modified operation s merges the second terminal of the first graph with the first terminal of the second graph, and then smooths away the merged vertex, as illustrated in Figure 4.
The method for calculating the pgd of a dmt-string is given in Section 5.
Step (4).This step concerns the composition of an amalgamation of two double-rooted graphs with univalent roots at one pair of univalent roots, followed by a self-amalgamation at the other two roots.See Section 6 for a description of this computation.
Step (5).This step is the composition of an amalgamation of two double-rooted graphs with univalent roots at one pair of univalent roots, followed by a self-amalgamation at the other two roots.See Section 6 for a description of this computation.

PGD of DMT-Strings
Four parallel productions and four series productions will be sufficient to calculate the values of the partials of any dmt-string.The following two sets of four productions each are sufficient to calculate all the partials of a dmt-string.The parallel productions are derived with the aid of Figures 5, 6, and 7.The series productions are self-evident.The genus of each resultant embedding is calculated from its Euler characteristic.

Examples
Our first example is the dmt-string D2 of Figure 8, which is of fundamental use in our further calculations.
Here we use pgd (which stands for partitioned genus distribution) as a function.We observe that D2 is representable as We now apply Eq. ( 7) and the productions above to calculate the partials of the three dmt-strings of the graph of Figure 9.

s t
Fig. 9: A cubic series-parallel graph.
The top dmt-string N 1 is representable as D2 s D2 .Therefore, 8), ( 9), (10), ( 11) The dmt-string N 2 is representable as D2 s ( D2 p K 2 ).Therefore, The dmt-string N 3 is representable as D2 p D2 .Therefore, 6 Amalgamating DMT-Strings A parallel operation on two dmt-strings yields a series-parallel graph whose source and target roots are both 2-valent.Figure 10 illustrates the productions used to transform the partials of the two antecedent dmt-strings into the partials of the consequent series-parallel graph.We define two partials for the case where p and q are both bivalent and a single walk is twice incident at each: = the number of embeddings G → S i such that the fb-walks twice incident at p and q are different; ss i (G, p, q) = the number of embeddings G → S i such that the same fb-walk is twice incident at p and q.We also define dd i (G, p, q) = the number of embeddings G → S i such that the same two fb-walks are twice incident at p and q.
Once again, the genus of each resultant embedding is calculated from its Euler characteristic.Continuing with our example of the graph from Figure 5.5, these productions enable us, in turn, to calculate pgd(N 1 p N 2 ).
The following six productions will enable us to complete our calculation of the genus distribution of the graph of Figure 9, starting from the pgd (21) for N 1 p N 2 and the pgd (16) for N 3 .We observe that the result of applying these productions is a genus distribution, rather than a partitioned genus distribution.Accordingly, the consequents are of the form g i rather than subscripted partials, thereby indicating only that the resulting embedding surface is S i .
By summation of the right-hand sides of the equations above, we obtain the genus distribution Proof: Choosing an edge and its endpoints s and t, as required by Step (1), takes constant time.The time needed for Step (2), which is achieved by partitioning the edge-set of the given graph G into the edge-sets of the three dmt-strings, is linear in the number of vertices of G, using depth-first search.
When two subgraphs are amalgamated during Step (3), the contribution to the partials of the merged graph corresponding to a pair of nonzero-valued subscripted partials, one in the pgd of the first amalgamand and the other in the pgd of the second amalgamand, is calculated by the application of one of the Productions (4), . . ., (11).Since the number of nonzero-valued subscripted partials for any graph is linear in the number of vertices, the time to calculate the pgd of the merged graph is proportional to the product of the numbers of vertices in the two amalgamands.Suppose that the numbers of vertices of the fragments of an dmt-string are x 1 , x 2 , . . ., x p .Since the vertices in two different fragments will be merged into a combined fragment only once during the reassembly of the dmt-string, the number of applications of productions during the entire reassembly is at most i =j x i x j However, i =j from which we infer that the total time is at most quadratic in the number of vertices of the dmt-string.
To see that Step (4) can be done in quadratic time, first observe that the number of nonzero partials in pgd(N 1 ) and pdg(N 2 ) is linear in the maximum genus of N 1 and N 2 , since partials can be nonzero only for genera with genus less than or equal to maximum genus and for every genus in this range there is only a constant number of different types of partials.Furthermore, it is well known that the maximum genus of any graph G is bounded from above by β(G), the cycle rank of G, which in turn is linear in the number of vertices for any graph with maximum degree 3. Accordingly, there is only a linear number of nonzero partials for both N 1 and N 2 , yielding at most a quadratic number of combinations needed to calculate pdg(N 1 p N 2 ).Finally, each combination of two partials can be computed in constant time using appropriate choices from Productions (4), . . ., (7), which implies that Step (4) can indeed be done in quadratic time in the number of vertices.
The argument that Step (5) uses only quadratic time is similar to that for Step (4) -the number of nonzero partials is again linear in the number of vertices; and each computation, this time involving one of the Productions (22), . . ., (27), can be done in constant time. 2

X
This calculation has been confirmed by a computer program based on the Heffter-Edmonds algorithm.Theorem 6.1 The time required by Algorithm 4.1 is at most quadratic in the number of vertices of the graph G supplied as input.