Crossing Minimization in Perturbed Drawings

08/23/2018 ∙ by Radoslav Fulek, et al. ∙ 0

Due to data compression or low resolution, nearby vertices and edges of a graph drawing may be bundled to a common node or arc. We model such a `compromised' drawing by a piecewise linear map φ:G→R^2. We wish to perturb φ by an arbitrarily small ε>0 into a proper drawing (in which the vertices are distinct points, any two edges intersect in finitely many points, and no three edges have a common interior point) that minimizes the number of crossings. An ε-perturbation, for every ε>0, is given by a piecewise linear map ψ_ε:G→R^2 with φ-ψ_ε<ε, where . is the uniform norm (i.e., norm). We present a polynomial-time solution for this optimization problem when G is a cycle and the map φ has no spurs (i.e., no two adjacent edges are mapped to overlapping arcs). We also show that the problem becomes NP-complete (i) when G is an arbitrary graph and φ has no spurs, and (ii) when φ may have spurs and G is a cycle or a union of disjoint paths.



There are no comments yet.


page 1

page 2

page 3

page 4

This week in AI

Get the week's most popular data science and artificial intelligence research sent straight to your inbox every Saturday.

1 Introduction

A graph is a 1-dimensional simplicial complex. A continuous piecewise linear map maps the vertices in into points in the plane, and the edges in to piecewise linear arcs between the corresponding vertices. However, several vertices may be mapped to the same point, and two edges may be mapped to overlapping arcs. This scenario arises in applications in cartography, clustering, and visualization, due to data compression, graph semantics, or low resolution. Previous research focused on determining whether such a map can be “perturbed” into an embedding. Specifically, a continuous piecewise linear map is a weak embedding if, for every , there is an embedding with , where is the uniform norm (i.e., norm). Recently, Fulek and Kynčl [11] gave a polynomial-time algorithm for recognizing weak embeddings, and the running time was subsequently improved to for simplicial maps by Akitaya et al. [2]. Note, however, that only planar graphs admit embeddings and weak embeddings. In this paper, we extend the concept of -perturbations to nonplanar graphs, and seek a perturbation with the minimum number of crossings.

A continuous map of a graph to a 2-manifold is a drawing if (i) the vertices in are mapped to distinct points in , (ii) each edge is mapped to a Jordan arc between two vertices without passing through any other vertex, and (iii) any two edges intersect in finitely many points. A crossing between two edges, , is defined as an intersection point between the relative interiors of the arcs and . For a piecewise linear map , let be the minimum nonnegative integer such that for every , there exists a drawing with and crossings, see Fig. 1 for an illustration.

Figure 1: An example for a map , where , i.e., a path of length 10, with (left); and a perturbation witnessing that (right).

It is clear that is a weak embedding if and only if . Note also that if and the arcs and cross transversely at some point , then and also cross in the -neighborhood of for any sufficiently small . An -perturbation may, however, remove tangencies and partial overlaps between edges.

The problem of determining for a given map is NP-complete: In the special case that is a single point, equals the crossing number of , and it is NP-complete to find the crossing number of a given graph [12] (even if is a planar graph plus one edge [5]).

In this paper, we focus on the special case that is a cycle. A series of recent papers [1, 6, 8] show that weak embeddings can be recognized in time. Chang et al. [6] identified two features of a map that are difficult to handle: A spur is a vertex whose incident edges are mapped to the same arc or overlapping arcs, and a fork is a vertex mapped to the relative interior of the image of some nonincident edge (a vertex may be both a fork and a spur). We prove the following results.

Theorem 1.1

Given a cycle and a piecewise linear map , where has vertices and the image is a plane graph with vertices, then can be computed

  1. in time if has neither spurs nor forks,

  2. in time if has no spurs.

As noted above, the problem of determining is NP-complete when is an arbitrary graph (even if is a constant map). We show that the problem remains NP-complete if is a cycle and we drop the condition that has no spurs.

Theorem 1.2

Given and a piecewise linear map , it is NP-complete to decide whether if may have spurs and

  1. is a cycle, or

  2. is a union of disjoint paths.

Related previous work. Finding efficient algorithms for the recognition of weak embeddings , where is an arbitrary graph, was posed as an open problem in [1, 6, 8]. The first polynomial-time solution for the general version follows from a recent variant [11] of the Hanani-Tutte theorem [13, 18], which was conjectured by M. Skopenkov [17] in 2003 and in a slightly weaker form already by Repovš and A. Skopenkov [16] in 1998. Weak embeddings of graphs also generalize various graph visualization models such as strip planarity [3] and level planarity [15]; and can be seen as a special case [4] of the notoriously difficult cluster-planarity (for short, c-planarity[9, 10], whose tractability remains elusive today.

Organization. We start in Sec. 2 with preliminary observations that show that determining is a purely combinatorial problem, which can be formulated without metric inequalities. We describe and analyse a recognition algorithm, proving Theorem 1.1 in Sec. 3. We prove NP-hardness by a reduction from 3SAT in Sec. 4, and conclude in Sec. 5. Omitted proofs are available in the Appendix.

2 Preliminaries

We rely on techniques introduced in [1, 6, 7, 11], and complement them with additional tools to keep track of edge crossings. A piecewise linear function is a composition , where is a continuous map from to a graph (i.e., a 1-dimensional simplicial complex) and is a drawing of . We may further assume, by subdividing the edges of if necessary, that the map is simplicial, that is, it maps vertices to vertices and edges to edges; and is a straight-line drawing of , where each edge in is mapped to a line segment. To distinguish the graphs and in our terminology, has vertices and edges , and has clusters and pipes .

A perturbation of lies in the -neighborhood of . We define suitable neighborhoods for the graph , and the image . For the graph and its drawing , we define the neighborhood as the union of regions and for every and , respectively, as follows. Let be a sufficiently small constant specified below. For every , let be the closed disk of radius centered at . For every edge , let be the set of points at distance at most from that lie in the interior of neither nor . Let be so small that for every triple , the disk is disjoint from both and , and the regions and are disjoint from each other. (Note, however, that regions and may intersect if the line segments and cross.)

Such exists due to piecewise linearity of and by compactness. (Indeed, consider the intersection and of the boundary of with that of and , respectively. Taking sufficiently small, we assume that and are line segments meeting in at some angle . We require since we need for and to be disjoint, and hence and .) By definition, an -perturbation of lies in the neighborhood for all .

For the graph and its drawing , we also define the thickening , , as a 2-dimensional manifold with boundary as follows. For every , create a topological disk , and for every edge , create a rectangle . For every and , fix an arbitrary orientation of and , respectively. Partition the boundary of into arcs, and label them by , for all , in the cyclic order around determined by the rotation of in the the drawing . The manifold is obtained by identifying two opposite sides of every rectangle with and via an orientation preserving homeomorphism. Note that there is a natural map such that ; is a homeomorphism between and for every ; and maps to for every .

We reformulate a problem instance as two functions and , where and are abstract graphs, is a simplicial map and is a straight-line drawing of . A perturbation of the map is a drawing , where is a drawing of on with the following properties:

  • for every vertex , ,

  • for every edge , such that it crosses the boundary of the disks and precisely once, and

  • all crossing between arcs , , lie in the disks , ;

and maps the disk injectively into for all , and rectangle into for all (however the rectangles and may be mapped to crossing neighborhoods and for two independent edges ).

Combinatorial Representation. Properties (P1)–(P3) allow for a combinatorial representation of the drawing : For every pipe , let be a total order of the edges in in ; and let the collection of these total orders. In fact, we can assume that consists of straight-line segments in every rectangle , and every disk . The number of crossings in each disk is determined by the cyclic order of the segment endpoints along . Thus the number of crossings in all disk , is determined by .

Two Types of Crossings. The reformulation of the problem allows us to distinguish two types of crossings in a piecewise-linear map : edge-crossings in the neighborhoods , , and crossings between edges mapped to two pipes that cross each other.

The number of crossings between the edges of inside a disk , , is the same as the number of crossings in , since is injective on . We denote the total number of such crossings by

where is the number of crossings of the drawing in the disk .

Let the weight of a pipe be the number of edges of mapped to , that is, . If the arcs and cross in the plane, for some , then every edge in crosses all edges in . The total number of crossings between the edges of attributed to the crossings between pipes is

where is the multiset of pipe pairs such that and cross. It is now clear that


The operations in Section 3 successively modify an instance until becomes a cycle. In this case, it is easy to determine , which is a consequence of the following folklore lemma.

Lemma 1

[14, Lemma 1.12] If and and is a simplicial map without spurs, where the cycle winds around the cycle precisely times, then .

3 Cycles without Spurs

Let be a cycle with vertices, and an arbitrary abstract graph, a simplicial map that does not map any two consecutive edges of to the same edge in , and a straight-line drawing. In this section, we prove that is invariant under the so-called ClusterExpansion and PipeExpansion operations. (Similar operations for weak embeddings have been introduced in [1, 6, 7, 11].) We show that a sequence of operations produces an instance in which is a cycle, where we can easily determine both and , hence .

Figure 2: ClusterExpansion.

ClusterExpansion. See Figure 2 for an illustration. (1) Let be a sufficiently small disk centered at that intersects only the images of pipes incident to . (2) Subdivide every pipe incident to with a new cluster , let . (3) Subdivide every edge such that with a new vertex such that . (4) For every vertex , and any two neighbors and , insert an edge in , insert a pipe in if it is not already present, and draw this pipe in the plane as a straight-line segment between and . (5) Delete cluster from , and delete all vertices in from . (6) Return the resulting instance by and .

Lemma 2

If is a cycle, has no spur, and , then ClusterExpansion produces an instance where is a cycle, has no spur, and .

We remark that is invariant under the ClusterExpansion operation even in the presence of spurs, however the proof is somewhat simpler in the absence spurs, and Lemma 2 also establishes that ClusterExpansion does not create new spurs.

Figure 3: PipeExpansion for a safe pipe .

Pipe Expansion. A cluster is a base of an incident pipe if every vertex in is incident to an edge in . A pipe is safe if both and are bases of . The following operation is defined on safe pipes. See Figure 2 for an illustration. (We note that our algorithm would be correct even if PipeExpansion were defined on all pipes, unlike the result in [2], since does not contain spurs. We restrict this operation to safe pipe to simplify the runtime analysis.)

PipeExpansion. (1) Let be a sufficiently narrow ellipse with foci at and that intersects only the images of pipes incident to and . (2) Subdivide every pipe incident to or with a new cluster , let . (3) Subdivide every edge such that and with a new vertex such that . (4) For every edge , and the two neighbors and of and , respectively, insert an edge in , insert a pipe in if it is not already present, and draw this pipe in the plane as a straight-line segment between and . (5) Delete clusters and from , and delete all vertices in from . (6) Return the resulting instance by and .

Lemma 3

If is a cycle, has no spur, and is a safe pipe, then PipeExpansion produces an instance where is a cycle, has no spur, and .

We remark that Lemma 3 holds even for that is not safe, provided that has no spur.

Main Algorithm. Given an instance and , we apply the two operations defined above as follows.

Algorithm 1. Input:
for every  do
while there is a safe pipe such that or  do
an arbitrary edge in . return .
Lemma 4

Algorithm 1 terminates.


By Lemmas 2 and 3, has no spurs in any step of the algorithm. It is enough to show that the while loop of Algorithm 1 terminates. We define the potential function , and show that and it decreases in every invocation of PipeExpansion. Since is a cycle and has no spur, every edge in is adjacent to one edge in some other pipe incident to and one edge in some other pipe incident to . Each of these edges contributes to one edge in inside the ellipse . Since is safe, has no other new edges. Consequently, . Since or , PipeExpansion replaces the clusters and with at least 3 clusters, each of which is incident to at least one pipe in the ellipse . Consequently, , and so , as claimed.

Lemma 5

At the end of the while loop of Algorithm 1, is a cycle.


It is enough to show that if is not a cycle in the while loop of Algorithm 1, then there is a safe pipe such that or . Observe that every cluster created by ClusterExpansion (resp., PipeExpansion) is a base for the unique incident pipe in the exterior of disk (resp., ellipse ). Let be a function that maps every cluster to that incident pipe. Note also that the input does not have spurs, and no spurs are created in the algorithm by Lemmas 2 and 3. In the absence of spurs, if and , then is a base for both incident pipes.

Assume that in some step of the while loop, is not a cycle. Let be an arbitrary cluster such that . Construct a maximal simple path incrementally such that for . If the path encounters a cluster where , then the pipe is safe. Similarly, if , then is safe. Otherwise, the path ends with a repeated cluster: , for some , and so we obtain a cycle of at least 3 vertices. Let , , be the cluster created in the most recent ClusterExpansion or PipeExpansion operation. Then is a pipe in the exterior of a disk or an ellipse . Hence, the pipe is in the interior of or , moreover and were created by the same operation. However, this implies , contradicting the assumption that is a cycle. We conclude that the path finds a safe pipe before any cluster repeats.

Lemma 6

Algorithm 1 returns .


By (1), . Here can be computed by a line sweep of the drawing . By Lemmas 1 and 5, at the end of the algorithm, for an arbitrary edge . By Lemmas 2 and 3, is invariant in the operations, so the algorithm reports for the input instance.

Running Time. The efficient implementation of our algorithm relies on the following data structures. For every cluster we maintain the set of vertices of in . For every pipe , we maintain , the weight , and the sum of weights of all pipes that cross , that we denote by . Then we have . We also maintain the current value of . We further maintain indicator variables that support checking the conditions of the while loop in Algorithm 1: (i) whether the cluster is a base for the pipe, (ii) whether a cluster has degree 2, and (iii) whether a pipe is safe.

Lemma 7

With the above data structures, Algorithm 1 runs in time, where and .

4 NP-Completeness in the Presence of Spurs

In this section, we prove Theorem 1.2. In a problem instance, we are given a simplicial map , a straight-line drawing , and a nonnegative integer , and ask whether .

Lemma 8

The above problem is in NP.


A feasible drawing with can be witnessed by a combinatorial representation of . Specifically, we can determine by computing the weight of each pipe in time, and finding all edge-crossings in the drawing in time. Given a combinatorial representation of a drawing , we can determine the number of crossings at all nodes in time.

We prove NP-hardness by a reduction from 3SAT. Let be a boolean formula in 3CNF with a set of variables and a set of clauses. We construct graphs and , a simplicial map , a straight-line drawing , and an integer such that if and only if is satisfiable.

First Construction: Disjoint Union of Paths. Refer to Fig. 4.

Figure 4: Two embeddings of . Top: is above . Bottom: is below .

Construction of and . For every variable , create a path .

For , the -th clause is associated to at most three (negated or non-negated) variables, say, . Identify the clusters for and we denote the resulting clusters also by and associate them with clause . Add two new clusters an , and two new pipes and . This completes the description of .

For every , we map clusters to integer points on the -axis. The two additional clusters, and , are mapped to points and , above and below the -axis. The remaining clusters and pipes of , , are mapped to integer points in the horizonal line . Specifically, , for , except for clusters that have been merged and incorporated in clause gadgets.

Observation 1

For every , is an -monotone polygonal path in the plane. This ensures, in particular, that if contains variables , , and , then the pipes of , , and that enter and exit appear in reverse ccw order in the rotation of and , respectively.

Construction of and . For each clause , create a path of 4 vertices mapped to . For each variable , create a path as follows. First create a path of vertices as a concatenation of three paths: , , and , which are mapped to , , and , respectively. We shall modify and within each cluster. Regardless of these local modifications, in every embedding of , the path lies between and . The truth value of variable is encoded by the above-below relationship between and (Fig. 4(a-b)).

Each pair , where a literal or appears in , corresponds to the subpath of . Suppose that a subpath and are mapped to this subpath. To simplify notation, we assume that and are directed from to .

Refer to Fig. 5. If contains the non-negated , then replace on with a subpath mapped to and with a subpath mapped to . If contains the negated then replace with , and with . This completes the definition of .

The drawing and determine . Let . Note that and have vertices and edges, and the drawing maps the clusters in to integer points in an grid.

Figure 5: A clause gadget for , where and . The neighborhood of the four middle “vertically prolonged” clusters and pipes between them forms .

Equivalence. First, we show that the satisfiability of implies that . Assume that is satisfiable, and let be a satisfying truth assignment. Fix . For every , denote by the union of disks and for all clusters and pipes ; and similarly let be the union of such regions for the path in . For every , incrementally, embed the path in as follows: each edge is an -monotone Jordan arc; if , then lies above ; otherwise lies above . If a clause contains variables , we also ensure that the embeddings of , , and are pairwise disjoint within . This is possible by Observation 1. Finally, for , embed the path as follows. Assume that contains the variables , where corresponds to a true literal in . Then starts from along the vertical line until it crosses the arc , then follows to the vertical line , and continues to along that line. Note that crosses only 3 edges in , and 5 edges in and . So there are 13 crossings in for ; and the total number of crossings is , as required.

Second, we show that implies that is satisfiable by constructing a satisfying assignment. Consider functions and such that is a drawing in which . Note that crossings are unavoidable due to edge-crossings in the drawing . Hence, by the definition of , there are at most crossings in the neighborhoods of clusters. We show that (1) there must be precisely 13 crossings in each neighborhood , (2) is an embedding for every , and (3) the embeddings of , for all , jointly encode a satisfying truth assignment for . (1) and (2) is established by the following lemma.

Lemma 9

Let and let be the three variables in . In , there are at least 13 crossings in neighborhood , and equality is possible only if none of the drawings , , has self-crossings in , and at least one of and is crossed exactly 3 times by .

By Lemma 9, implies that defines an embedding of , for all , in each region , . Consequently, defines an embedding of in for all . In every embedding , for , either lies above , or vice versa. We can now define a truth assignment such that for every , if and only if lies above in .

Lemma 10

Assume that is an embedding for every , which determines the truth assignment described above. For every , if variable appears in clause , and crosses at most 3 times in , then appears as a true literal in .


Consider the highest and lowest path and among or , respectively, in , none of which can be since is an embedding. By the construction of , either there exists exactly one pipe-degree 2 component of in and exactly one pipe-degree 2 component of in , or vice versa.

By the construction of , crosses each of , , and at least once in . By the hypothesis of the lemma, it crosses each exactly once. Then has only one pipe-degree 2 component in , and has only one pipe-degree 2 component in . By the construction of , if appears as a non-negated literal in this means that lies above and therefore . Similarly, if appears as a negated literal in this means that lies above and therefore . Consequently, appears as a true literal in and that concludes the proof.

Since , for every , there are exactly 13 crossings in by Lemma 9. Moreover, by Lemma 9 the drawing is an embedding for every , and in every for one its variables the drawing of is crossed by exactly 3 times. By Lemma 10, the assignment makes at least one literal in each clause of true. We conclude that is satisfiable, as required. This completes the proof of NP-hardness.

Second Construction: Cycle. In our first construction, is a disjoint union of paths, and for every path endpoint , is the only vertex mapped to the cluster . This property allows us to expand the construction as follows. We augment into a cycle by adding a perfect matching connecting the path endpoints, and we augment with the corresponding matching between the clusters , and for every new pipe draw a polygonal arc between and that does not pass through the image of any other cluster (but may cross images of other pipes). The augmentation does not change , and we can easily compute the increase in due to new crossings. Consequently, finding remains NP-hard.

5 Conclusions

Motivated by recent efficient algorithms that can decide whether a piecewise linear map can be perturbed into an embedding, we investigate the problem of computing the minimum number of crossings in a perturbation. We have described an efficient algorithm when is a cycle and has no spurs (Theorem 1.1); and the problem becomes NP-hard if is an arbitrary graph, or if is a cycle but may have spurs (Theorem 1.2). However, perhaps one can minimize the number of crossings efficiently under milder assumptions. We formulate one promising scenario as follows: Is there a polynomial-time algorithm that finds when is a planar graph (resp., an edgeless graph) for every cluster and has no spurs?


  • [1] Akitaya, H.A., Aloupis, G., Erickson, J., Tóth, Cs.D.: Recognizing weakly simple polygons. Discrete Comput. Geom. 58(4), 785–821 (2017).
  • [2] Akitaya, H.A., Fulek, R., Tóth, Cs.D.: Recognizing weak embeddings of graphs. In: Proc. 29th ACM-SIAM Symposium on Discrete Algorithms (SODA). pp. 274–292. SIAM (2018).
  • [3] Angelini, P., Da Lozzo, G., Di Battista, G., Frati, F.: Strip planarity testing for embedded planar graphs. Algorithmica 77(4), 1022–1059 (2017).
  • [4] Angelini, P., Lozzo, G.D.: Clustered planarity with pipes. In: Hong, S.H. (ed.) Proc. 27th Internat. Sympos. on Algorithms and Computation (ISAAC). LIPIcs, vol. 64, pp. 13:1–13:13. Schloss Dagstuhl (2016).
  • [5] Cabello, S., Mohar, B.: Adding one edge to planar graphs makes crossing number and 1-planarity hard. SIAM Journal on Computing 42(5), 1803–1829 (2013).
  • [6] Chang, H.C., Erickson, J., Xu, C.: Detecting weakly simple polygons. In: Proc. 26th ACM-SIAM Symposium on Discrete Algorithms (SODA). pp. 1655–1670 (2015).
  • [7] Cortese, P.F., Di Battista, G., Patrignani, M., Pizzonia, M.: Clustering cycles into cycles of clusters. J. Graph Alg. Appl. 9(3), 391–413 (2005).
  • [8] Cortese, P.F., Di Battista, G., Patrignani, M., Pizzonia, M.: On embedding a cycle in a plane graph. Discrete Math. 309(7), 1856–1869 (2009).
  • [9] Feng, Q.W., Cohen, R.F., Eades, P.: How to draw a planar clustered graph. In: Du, D.Z., Li, M. (eds.) Proc. 1st Conference on Computing and combinatorics (COCOON), LNCS, vol. 959, pp. 21–30. Springer, Berlin (1995).
  • [10] Feng, Q.W., Cohen, R.F., Eades, P.: Planarity for clustered graphs. In: Spirakis, P. (ed.) Proc. 3rd European Symposium on Algorithms (ESA). LNCS, vol. 979, pp. 213–226. Springer, Berlin (1995).
  • [11] Fulek, R., Kynčl, J.: Hanani-Tutte for approximating maps of graphs. In: Proc. 34th Symposium on Computational Geometry (SoCG). LIPIcs, vol. 99, pp. 39:1–39:15. Dagstuhl, Germany (2018).
  • [12] Garey, M.R., Johnson, D.S.: Crossing number is NP-complete. SIAM. J. on Algebraic and Discrete Methods 4(3), 312–316 (1982).
  • [13] Hanani, H.: Über wesentlich unplättbare Kurven im drei-dimensionalen Raume. Fundamenta Mathematicae 23, 135–142 (1934).
  • [14] Hass, J., Scott, P.: Intersections of curves on surfaces. Israel Journal of Mathematics 51(1), 90–120 (1985).
  • [15] Jünger, M., Leipert, S., Mutzel, P.: Level planarity testing in linear time. In: Whitesides, S.H. (ed.) Proc. 6th Symposium on Graph Drawing (GD), LNCS, vol. 1547, pp. 224–237. Springer, Berlin (1998).
  • [16] Repovš, D., Skopenkov, A.B.: A deleted product criterion for approximability of maps by embeddings. Topology Appl. 87(1), 1–19 (1998).
  • [17] Skopenkov, M.: On approximability by embeddings of cycles in the plane. Topology Appl. 134(1), 1–22 (2003).
  • [18] Tutte, W.T.: Toward a theory of crossing numbers. J. Combin. Theory 8, 45–53 (1970).

Appendix 0.A Omitted Proofs

Lemma 2If is a cycle, has no spur, and , then ClusterExpansion produces an instance where is a cycle, has no spur, and .


If is a cycle, then every vertex has precisely two neighbors, say and . Step 3 subdivides these edges with new vertices and , Step 4 inserts an edge , and Step 6 deletes . Consequently, the path is replaced by a path . Since all such paths are edge-disjoint, the resulting graph is a cycle.

Since has no spur, for every vertex , the neighbors and are in distinct clusters, that is . Consequently, and so . Therefore the operation does not create spurs.

Let be a drawing that attains . We may assume that every connected component of and is a straight-line segment.

Let and be two different paths in such that . There are two types of crossings of in between paths and as above. In the first type, and interleave in the rotation at with and . In the second type, we have ,