1 Introduction

Schnyder woods [27] and its generalizations are a deep tool for dealing with the combinatorics of planar [13] and surface maps [10, 11, 18]. They lead to efficient algorithmic and combinatorial solutions for a broad collection of problems, arising in several domains, from enumerative combinatorics to graph drawing and computational geometry. For instance, the use of Schnyder woods has led to linear-time algorithms for grid drawing [3, 18, 27], to the optimal encoding and uniform sampling of planar maps [26], to the design of compact data structures [9] and to deal with geometric spanners [5]. Schnyder woods lead to fast implementations (also integrated in open source libraries [25]) and provide strong tools for establishing rigorous theoretical guarantees that hold in the worst case, even for irregular, random or pathological cases. The main idea motivating this work is that, in practice, most real-word graphs exhibit strong regularities which make them far from the random and pathological cases. Based on this remark, many geometry processing algorithms try to exploit this regularity in order to obtain better results in practice. For instance, when applied to regular graphs, many mesh compression schemes [19] achieve good compression rates, well below the worst-case optimal bound guaranteed by [26]. As far as we know, the problem of providing an adaptive analysis of Schnyder woods taking into account the graph regularity has not been investigated so far. This work provides empirical evidence about the fact that balanced Schnyder woods can lead to fast solutions achieving good results in practice, especially for real-world graphs. As test applications, we evaluate the layout quality of a Schnyder drawing depending on the balance of the underlying Schnyder wood, and we consider the problem of computing small separators for planar graphs, which has been extensively investigated [22,23,24, 28], due to its relevance for many graph algorithms.

Fig. 1.
figure 1

(a) A planar triangulation endowed with a Schnyder wood. (b) a separator (A, B, S) obtained from the Schnyder wood. (c) three Schnyder woods of the same portion of a spherical grid: our heuristic leads to a majority of balanced vertices (white circles), while the minimal Schnyder wood is strongly unbalanced. (Right chart) Evaluation of the balance of Schnyder woods (tests are repeated with 500 random seeds) (Color figure online).

Preliminaries and Related Works. In this work we deal with planar triangulations, which are genus 0 simple maps where every face is triangulated (we will denote by n the number of vertices and by m the number of edges). Given a planar triangulation with a distinguished root (outer) face \((v_0, v_1, v_2)\), a Schnyder wood [27] is defined as a coloring (with colors 0, 1 or 2) and orientation of the inner edges such that each inner vertex has exactly one outgoing incident edge for each color, and the remaining incident edges must satisfy the local Schnyder rule (see Fig. 1(a)). A given rooted triangulation may admit many Schnyder woods [1, 2, 14]: among them, the minimal one (without ccw oriented triangles) plays a fundamental role [9, 26]. Here we focus on balanced Schnyder woods, for which the ingoing edges are evenly distributed around inner vertices. A related problem concerns the computation of egalitarian orientations: unfortunately the results in [6] only apply to unconstrained orientations. Schnyder woods have led to a linear-time algorithm providing an elegant solution to the grid drawing problem (solved independently also in [17]): in its pioneristic work [27] Schnyder showed that a planar graph with n vertices admits a straight-line drawing on a grid of size \(O(n)\times O(n)\). Schnyder drawings have a number of nice properties that make them useful for addressing problems [4, 5, 12] involving planar graphs in several distinct domains. While recent works [21] provide a probabilistic study of the converge for uniformly sampled triangulations endowed with a Schnyder wood, as far as we know there are no theoretical or empirical evaluations of the quality of Schnyder drawings for regular graphs. Given a graph G we consider small separators which are defined by a partition (A, B, S) of all vertices such that S is a separating vertex set of small size (usually \(|S|=O(\sqrt{m})\)), and the remaining vertices in \(G\setminus S\) belong to a balanced partition (A, B) satisfying \(|A|\le \alpha n\), \(|B|\le \alpha n\) (usually, for planar graphs, the balance ratio is \(\alpha =\frac{2}{3}\)). Here we focus on simple cycle separators [24], for which fast implementations [16, 20] have been recently proposed (some of them [16] are provided with a worst-case bound of \(\sqrt{8m}\) on the cycle size).

2 Contribution

2.1 Balanced Schnyder Woods

Our first step is to measure the balance of a Schnyder wood: given an inner vertex v of degree deg(v) having \(indeg_{i}(v)\) incoming edges of color i (for \(i\in \{0, 1, 2\}\)), we define its defect as \(\delta (v)=\max _{i} indeg_i(v) - \min _{i} indeg_{i}(v)\) if deg(v) is a multiple of 3, and \(\delta (v)=\max _{i} indeg_i(v) - \min _{i} indeg_{i}(v) - 1\) otherwise. We say that a vertex is balanced if \(\delta (v)=0\) and a Schnyder wood is well balanced if a majority of vertices have a small defect. For regular graphs is possible, in principle, to get a Schnyder wood that is perfectly balanced (\(\delta (v)=0\) everywhere) as shown in Fig. 1(c). In practice many Schnyder woods are unbalanced and we are not aware of existing theoretical or empirical results on the balance of Schnyder woods.

An Heuristic for Well Balanced Schnyder Woods. We make use of the well known incremental vertex shelling procedure [7] that computes a Schnyder wood with a sequence of vertex removals. This procedure has many degrees of freedom: at each step the choice of the vertex to be removed can possibly lead to a different Schnyder wood. In order to get as much as possible balanced vertices, we retard the removal of some vertices according to a balance priority, defined as the total number of ingoing edges incident to a vertex during the shelling procedure. The balance can be further improved by performing the reversal of oriented triangles in a post-processingFootnote 1 step. We refer to [8] for more details.

2.2 From Schnyder Drawings to Small Simple Cycle Separators

Schnyder woods provides a very fast procedure for partitioning, given an arbitrary inner vertex v, the set of inner faces of a triangulation into three sets \(R_0(v)\), \(R_1(v)\) and \(R_2(v)\) (respectively blue, red and gray triangles in Fig. 1(b)), whose boundaries consist of the three disjoint paths \(P_0(v)\), \(P_1(v)\) and \(P_2(v)\) emanating from v. The computation of simple cycle separators can be done as follows: for each vertex v check whether the two sets \(A=Int(R_{i}(v)\cup R_{i+1}(v))\) and \(B=Int(R_{i+2}(v))\) satisfy the prescribed balance ratio for at least one index \(i\in \{0, 1, 2\}\) (indices are modulo 3, and Int(R) denotes the set of inner vertices of a region R): then select the vertex for which the corresponding cycle length \(|P_{i}(v)|+|P_{i+1}(v)|+1\) is minimal. All this steps can be performed almost instantaneously, since all the quantities above are encoded in the Schnyder drawing itself (see [27] for more details). As far as we know there are no theoretical guarantees on both the partition balance and boundary size: as observed in practice, most vertices lead to unbalanced partitions whose boundary size can be very large.

Fig. 2.
figure 2

Evaluation of timing costs over 100 executions (allocating 1 GB of RAM for the JVM): timings are expressed as a function of the size (millions of vertices).

2.3 Experimental Results

Datasets and Experimental Setting. We run our experimental evaluationsFootnote 2 on a broad variety of graphsFootnote 3, including real-world meshes used in geometry processing (made available by the aim@shape and Thingi10k repositories), synthetic regular graphs with different shapes (\(\texttt {sphere}, \texttt {cylinder}, ...\)), random planar triangulations (generated with uniform random sampling [26]), and Delaunay triangulations of random points. As done in geometric modeling, we use the proportion of degree 6 vertices, denoted by \(d_6\), to measure the regularity of a graph: \(d_6\) is close to 1 for regular meshes, while is usually below 0.3 for irregular and random graphs. To evaluate the balance of a Schnyder woods we use the proportion of balanced vertices, denoted by \(\delta _{0}\), and the average defect computed on all vertices, denoted by \(\delta _{avg}\). As for previous works [16, 20], the results (e.g. the size of the separator) can depend on the choice of the initial seed (the root face in our case). We perform tests with hundreds of random seeds: for each choice of the seed, we adopt whisker plots to show the entire range of computed values, while each box represents the middle 50% of values (as in Figs. 1 and 4).

Balance of Schnyder Woods. To evaluate the balance quality of the Schnyder woods we plot the value \(\delta _0\) as a function of \(d_6\): our balanced Schnyder woods are compared to minimal ones in Fig. 1. Experimental results strongly suggests that our heuristic leads to well balanced Schnyder woods. Our heuristic performs particularly well for regular graphs, for which a large majority of vertices are balanced (\(79\%\) in average for the sphere graph). The results are good also for irregular graphs (egea), where about \(45\%\) of vertices are balanced. Also observe that the choice of the initial seed has a limited effect on the balance of the resulting Schnyder wood. Minimal Schnyder woods represent a bad case, especially for regular graphs: most vertices have a large defect and the resulting paths \(P_0(v)\), \(P_1(v)\) and \(P_2(v)\) resemble very long spirals.

Runtime Performances. The algorithmic solutions relying on Schnyder woods are simple to implement and extremely fast. As observed in practice (see Fig. 2), our Java implementation allows processing between 1.43M and 1.92M vertices per second: we run our tests on an EliteBook with a core i7-5600U 2.60 GHz (with Ubuntu 16.04 and 1 GB of RAM allocated for the JVM). This has to be compared to the C implementations of previous results on cycle separators [16, 20], running on an Intel Xeon X5650 2.67 GHz (with 48.4 GB of RAM): the fastest variant of the procedures tested in [16] allows processing between 0.54M and 0.62M vertices per second for the case of square grids. Our timing costs are little affected by the choice of the initial seed and the structural properties of the graph. Observe that once the Schnyder drawing is given, the extraction of the cycle separator is instantaneous (0.01 s for a 1M vertices graph).

Fig. 3.
figure 3

For a fixed initial seed, we generate a sequence of Schnyder woods by starting from a well balanced Schnyder wood (computed with our heuristic) and by randomly reversing ccw oriented triangles. In the charts we plot the layout and separator quality as functions of the average defect \(\delta _{avg}\) of the corresponding Schnyder wood.

Layout Quality. A qualitative evaluation of the graph layouts based on the balance Schnyder woods is provided by the pictures in Fig. 3(a) showing two portions of the Schnyder drawings of a regular sphere graph. When starting from a our well balanced Schnyder woods the shape of triangles is much more balanced, and the resulting drawing partially captures the regularity of the grid. When starting from an unbalanced Schnyder wood the drawing exhibits many long edges and flat triangles, a typical drawback of Schnyder drawings. In order to provide a quantitative measure of the layout quality we consider the edge lengths aesthetic metric defined by \(\mathfrak {el}=1-d_{el}\), where \(d_{el}\) is the average percent deviation of edge lengths: values close to 1 mean that most edges have the same length (see [15] for more details). For a fixed initial seed, we start from a balanced Schnyder wood obtained with our heuristic and we randomly reverse ccw oriented triangles, obtaining a sequence of Schnyder woods which are more and more unbalanced. The middle chart in Fig. 3 reports the values of \(\mathfrak {el}\) as a function of the average defect: the layout quality tends to deteriorate as soon as Schnyder woods get more unbalanced (high values of \(\delta _{avg}\)).

Fig. 4.
figure 4

We evaluate the quality of our simple cycle separators obtained from our balanced Schnyder woods (tests are repeated using 200 random seeds). The left charts report the boundary sizes, while the right charts show the plots of the separator balance (the normalized size of the smallest of the two sets A and B). The graphs are listed from left to right according to the increasing values of their relative diameter.

Length and Balance of Separators. We look for separators with a balance ratio \(\alpha =\frac{2}{3}\) that are short: the boundary size is at most \(|S|\le \sqrt{8m}\), as required in [16]. We plot in the charts of Fig. 4 the boundary sizes and partition balances of the separators obtained from a Schnyder drawing as described in Sect. 2.1. Our tests, repeated over several tens of graphs, confirm our intuition that balanced Schnyder woods lead to good separators for a large majority of classes of graphs. As for the layout quality, the separator size and balance strongly depend on the balance of the underlying Schnyder wood (right chart in Fig. 3). The boundary size of the separator is affected by the choice of the seed for graphs with large diameter: a good choice of the seed would prevent from getting too long cycles. For graphs with small diameter (e.g. random triangulations) Schnyder woods lead to very short separators, while the size is closed to \(\sqrt{m}\) for most real-world graphs. Our separators are often longer when compared with the results obtained in [16], but well below the prescribed bound of \(\sqrt{8m}\).