Abstract 1 Introduction 2 Preliminaries 3 Multiple Distances in Clustered Planar Graphs 4 Girth for Line Segments References

Computing the Girth of a Segment Intersection Graph

Timothy M. Chan ORCID Siebel School of Computing and Data Science, University of Illinois Urbana-Champaign, IL, USA    Yuancheng Yu ORCID Siebel School of Computing and Data Science, University of Illinois Urbana-Champaign, IL, USA
Abstract

We present an algorithm that computes the girth of the intersection graph of n given line segments in the plane in O(n1.483) expected time. This is the first such algorithm with O(n3/2ε) running time for a positive constant ε, and makes progress towards an open question posed by Chan (SODA 2023). The main techniques include (i) the usage of recent subcubic algorithms for bounded-difference min-plus matrix multiplication, and (ii) an interesting variant of the planar graph separator theorem. The result extends to intersection graphs of connected algebraic curves or semialgebraic sets of constant description complexity.

Keywords and phrases:
Geometric intersection graphs, girth, shortest paths, graph separators, matrix multiplication
Funding:
Timothy M. Chan: Work supported by NSF Grant CCF-2224271.
Copyright and License:
[Uncaptioned image] © Timothy M. Chan and Yuancheng Yu; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Computational geometry
Related Version:
Full Version: https://arxiv.org/pdf/2603.21585
Editors:
Hee-Kap Ahn, Michael Hoffmann, and Amir Nayyeri

1 Introduction

Intersection graphs of geometric objects have received considerable attention in computational geometry. They generalize planar graphs (every planar graph is an intersection graph of disks in 2D by the Koebe–Andreev–Thurston theorem), and they arise in numerous applications (for example, unit disk graphs can be used to model communication networks, and intersection graphs of line segments in 2D can be used to model road networks). Over the years, researchers have studied many standard computational problems on geometric intersection graphs, aiming for algorithms that run faster than those for general graphs. The problems considered include the computation of connected components [1], all-pairs shortest paths [17], diameter [10, 15], minimum cut [12], maximum matching [6], and finding small-sized subgraphs (such as triangles, cycles of a fixed length, cliques of a fixed size, etc.) [14].

In this paper, we focus on another of the most basic graph algorithm problems, which has not been as well explored in the context of geometric intersection graphs: the computation of the girth, i.e., the length of the shortest cycle (see Figure 1). Girth is related to various topics in graph theory, including the chromatic number, treewidth, diameter, Ramsey theory, etc. [5, 22, 39, 27, 18, 23]. It can be computed in O(mn) or O(nω) time for general unweighted undirected graphs with n vertices and m edges [32], where ω<2.371339 is the matrix multiplication exponent [2]. For the case of planar graphs, a series of papers [24, 25, 13, 46] culminated in a linear-time algorithm by Chang and Lu [19]. However, for intersection graphs, we are aware of only two main algorithmic results:

Figure 1: An example of the shortest cycle of a segment intersection graph (segments not in the shortest cycle are dotted). The girth is 6.
  1. 1.

    Kaplan et al. at ESA’19 [33] gave an O(nlogn)-time algorithm for computing the girth of the intersection graph of n disks in 2D (in the case of unit disks, this was subsequently improved by Klost and Mulzer [35] to an O(n)-time algorithm which does not require the disks be given, just the graph).

  2. 2.

    Chan at SODA’23 [14] gave an O~(n3/2)-time111The O~ notation hides polylogarithmic factors. algorithm for computing the girth of the intersection graph of n line segments in 2D.

Chan’s work naturally raises the following question:

Is there an O(n3/2ε)-time algorithm for computing the girth of the intersection graph of n line segments for some constant ε>0?

The case of line segments is particularly important, not only because of direct relevance to road networks, for example, but also because it serves as a stepping stone towards the general case of algebraic curves or semialgebraic sets in the plane.

1.1 New result

We answer the above open question in the affirmative by presenting the first algorithm that breaks the n3/2 barrier. Specifically, our algorithm computes the girth for the intersection graph of n line segments in 2D in O(n1.483) expected time. The algorithm also extends to intersection graphs of algebraic curves or semialgebraic sets where each object is connected and has constant description complexity – essentially, most families of constant-size objects in 2D that are commonly encountered.

1.2 Why is the problem challenging?

First note that Kaplan et al.’s approach [33] is not applicable for our problem, as it exploited special properties of disks that do not hold for line segments (namely, that any intersection graph of disks with girth more than 3 must be planar). For the related problem of finding short cycles, Chan [14] extended Kaplan et al.’s result to arbitrary fat objects in any constant dimension, by using a shifted quadtree approach, but line segments are not fat.

For intersection graphs of line segments, Chan [14] has already given an O(n1.408)-time algorithm for detecting a triangle (i.e., 3-cycle), and an O~(n)-time algorithm for detecting a 4-cycle. Thus, it suffices to handle the remaining case when the girth is greater than 4. It is known that any intersection graph of n line segments without 4-cycles must be sparse, i.e., has O(n) edges. We can explicitly construct the arrangement of the line segments and form a planar graph of O(n) size whose vertices are the endpoints and intersection points. This way, our problem is reduced to a variant of the girth problem on a planar graph, where the cost of a cycle is the number of turns – turning at an intersection point has unit cost, but going straight through an intersection has zero cost.

However, this variant does not seem directly reducible to the standard girth problem on planar graphs. One could create a gadget at each intersection point and obtain a graph with 0/1 edge weights, such that the weight of a path in the new graph corresponds to the number of turns along the path. But the resulting graph would no longer be planar (it would be 1-planar instead); besides, unintended small cycles would be introduced in such a gadget. In addition, many properties about shortest paths in planar graphs no longer hold. For example, two shortest paths in a planar graph cannot cross more than once (if ties are broken carefully), but two minimum-turn paths may cross numerous times. Consequently, many techniques devised for shortest-path-related problems in planar graphs (e.g., based on some kind of Monge property [29], or abstract Voronoi diagrams [11, 30], or VC-dimension arguments [37, 26, 36, 15]) seem to fall apart for our problem.

One technique that still works is separators. In fact, Chan’s previous O~(n3/2)-time algorithm is obtained by a simple application of separators. We can divide the graph into two parts by a separator of size O(n), and recurse on both parts. This handles the case when the shortest cycle lies completely in one part. To deal with the remaining case when the shortest cycle passes through a separator vertex, we can run BFS from each of the O(n) separator vertices, in O~(n3/2) total time.

For the case when the girth is a constant (or for detecting a cycle of a fixed constant length), Chan [14] has shown how to adapt the separator approach to obtain a faster algorithm running in O~(nω/2)O(n1.186) time. The main observation is that the O(n) calls to BFS is overkill – we only need to compute shortest path distances with both sources and destinations from the O(n) separator vertices. We can compute such distances recursively as we compute the girth. Combining the output of the two recursive calls involves computing min-plus products of O(n)×O(n) distance matrices. When the matrix entries are integers bounded by a constant, min-plus product reduces to O(1) number of standard (Boolean) matrix product. This is roughly how the O~(nω/2) time bound was obtained.

For larger girth, however, this approach does not work well, because the complexity of min-plus product grows for larger integer values. (Another issue is the use of color-coding [3] in Chan’s cycle detection algorithm [14], which led to exponential dependence on the cycle length.)

On the other hand, when the girth g is very large, one could obtain an O~(n2/g)-time algorithm by a well-known hitting set technique [44, 47] (there exists a subset of O~(n/g) vertices which hit all shortest paths of length Ω(g)). The main difficulty lies in the intermediate case, when the girth is not too small and not too large.

1.3 Our approach

Ingredient 1: Bounded-difference min-plus matrix multiplication.

The previous separator-based approach faces an n3/2 barrier because min-plus matrix multiplication is widely conjectured to require near-cubic time (according to the “All-Pairs Shortest Paths (APSP) hypothesis” from fine-grained complexity [45]). Our first idea is to employ recent results which solve certain powerful special cases of min-plus product in truly subcubic time – namely, the case when the input matrices are integer-valued and satisfy a bounded-difference property, i.e., the difference between any two adjacent entries (in each row or in each column) is at most a constant. Chan and Lewenstein [16] gave the first truly subquadratic algorithm for the related min-plus convolution problem for bounded-difference sequences, while Bringmann et al. [9] gave the first truly subcubic algorithm for bounded-difference min-plus product. Bringmann et al.’s original algorithm ran in O(n2.8244) time, and after a series of improvements [31, 20], Chi et al. [21] obtained the current best running time of O~(n(3+ω)/2)O(n2.686) (see Section 2.1).

Bounded-difference min-plus convolution and matrix multiplication have recently been applied to solve a variety of problems from different domains, including language edit distance and RNA folding [9], single-source replacement paths and Range Mode [31], tree edit distance [40], approximate APSP [43], knapsack [7, 8], etc. Our algorithm, being one of the first applications to a computational geometry problem, is thus noteworthy.

Ingredient 2: A variant of the planar-graph separator theorem.

Why is the bounded-difference property relevant in our application? Suppose the separator S is connected, e.g., is a cycle (as in Miller’s version of the separator theorem [41]). Then for any vertex q and two adjacent separator vertices s,sS, d(s,q) and d(s,q) differ by at most 1 due to the triangle inequality. Thus, the distance matrices we encounter during recursion would indeed satisfy the bounded-difference property.

Unfortunately, cycle separators do not always exist when the given planar graph is not 2-connected. Our key idea is to use an interesting variant of the planar-graph separator theorem, which holds for any planar graphs: given any α>0, there always exists a separator S consisting of two subsets P and Q, where

  • the first subset P has size O(n1/2+α) but has at most 2 connected components (in fact, at most 2 paths);

  • the second subset Q may not be connected but has size O(n1/2α).

We are not aware of this variant of the separator theorem explicitly stated before (though we will not be surprised if it appeared before), but it follows by straightforward modification of standard proofs. See Section 2.2 for the precise statement and proof.

This variant of separators is exactly the tool we need to break the n3/2 barrier: since P has only O(1) connected pieces, we can use bounded-difference min-plus products to compute distances involving P faster; on the other hand, since Q has size n, we can afford to compute distances involving Q more naively. We choose the trade-off parameter α carefully to balance cost. This is the main high-level idea of our algorithm. Quite a bit of technical effort, however, is needed to make the idea work (for example, the number of connected components may grow as we recurse, but not by much, as we will show, and we eventually need two separate recursive algorithms, one for computing distances and one for computing the girth). See Sections 34 for the detailed algorithm and analysis.

Ingredient 3: Ensuring simplicity of walks.

When computing a shortest path between two vertices, we do not need to worry about ensuring simplicity of the path, since a shortest walk must automatically be a shortest path (if a vertex is repeated, we can take a short-cut to obtain a shorter walk). However, more care is needed for the shortest cycle problem in undirected graphs. When concatenating several shortest paths to form a candidate cycle (via min-plus products of several distance matrices), one potential issue is that the resulting closed walk might become trivial (we might be completely retracing our steps, so that short-cutting yields an empty walk!). The earlier algorithm by Chan [14] for detecting constant-length cycles used the color-coding technique [3] to ensure simplicity, but unfortunately color-coding yields exponential dependence on the cycle length. For general graphs, there are other strategies to ensure simplicity, (e.g., by computing shortest paths in different subgraphs with some vertices and edges removed, or with directions added, so as to avoid concatenating two identical shortest paths). But ensuring simplicity is trickier in our setting, since we need to retain the bounded-difference property if we work with new subgraphs. Still, we have found one way to deal with this technical issue, using ideas given in Section 2.3.

2 Preliminaries

Before presenting our algorithm, we begin by providing more details on the three ingredients mentioned in the introduction.

Let δG(u,v) denote the shortest-path length between u and v in an unweighted undirected graph G. Let δG[A,B] denote the distance matrix {δG(u,v)}uA,vB for two vertex subsets A and B in a graph G. Let G[S] denote the subgraph of G induced by a vertex subset S.

2.1 Bounded-difference min-plus product

Given two matrices A,B, their min-plus product AB is defined as

(AB)(i,j)=mink(A(i,k)+B(k,j)).

As mentioned, we will use a known subcubic algorithm for computing the min-plus product of two n×n integer matrices that satisfy a bounded-difference property. The following is due to Chi et al. [21]:

Lemma 1.

Given two integer n×n matrices A and B where each column of A satisfies the bounded-difference property (i.e., |A(i,j)A(i+1,j)|O(1) for every i,j), we can compute their min-plus product AB in O~(n(3+ω)/2)O(n2.686) expected time.

The same holds if instead each row of A satisfies the bounded-difference property (i.e., |A(i,j)A(i,j+1)|O(1)), or if the property holds for B rather than A.

2.2 A variant of the planar separator theorem

The second ingredient is an interesting variant of the planar-graph separator theorem, in which the separator is divided into two subsets P and Q: P may be larger but has only 2 connected pieces, while Q may not be connected but is smaller. The precise statement is given below (the original theorem corresponds to the case when p=n with unit loads, while our application requires the case when pn). The proof follows by modifying standard proofs [38, 34, 28].

Lemma 2.

Let G=(V,E) be a planar graph with n vertices, where each vertex has a nonnegative weight and a nonnegative load, with total weight W, total load Λ, and the maximum individual vertex weight is at most εW for a sufficiently small constant ε>0. For a given parameter p, we can partition V into subsets V1,V2,S, in O(n) time, such that

  • the total weight of Vi is at most 3W/4 for each i{1,2};

  • there are no edges in V1×V2;

  • S can be further partitioned into P and Q such that P is the union of at most two paths of length O(p), and Q has total load at most O(Λ/p).

Proof.

We first assume that G is connected. Let 𝒯 be a BFS tree of G from a fixed source vertex. For any uv𝒯, let cycle(𝒯,uv) denote the unique cycle in 𝒯{uv} (called the fundamental cycle), which consists of uv and the unique path in 𝒯 connecting u and v.

Let Σ be a (combinatorial) triangulation of 𝒯. Define face weights of Σ by examining each vertex v, picking an arbitrary incident face f, and adding v’s weight to f. Then the total face weight is W. Consider the dual tree with respect to 𝒯 in Σ (which has maximum degree 3). By standard results on tree separators [34, 28]. we can find an edge which separates this dual tree into two parts each with total face weight at most 3W/4. In Σ, this corresponds to an edge uv such that either side of C=cycle(𝒯,uv) has total face weight at most 3W/4; this also bounds the total weight of the vertices strictly inside/outside C. If |C|p then the desired separator can obtained by setting P=C and Q=. Below we may assume |C|>p.

Let x be the lowest common ancestor of u,v in 𝒯, and 𝒯 be the subtree of 𝒯. Let LiV be the set of vertices in level i of 𝒯 (with L0=). Let m be the smallest integer such that the total weight of vertices in the first m levels of 𝒯 is at least W/2. By the pigeonhole principle, there exists [mp,m) such that L has total load at most Λ/p. Similarly there exists h(m,m+p] such that Lh has total load at most Λ/p.

If V=i=1Li has weight at least W/4, then since V has weight at most W/2 by definition of m, the desired separator can be obtained by setting Q=L and P=.

Similarly, if Vh=i=hLi has weight at least W/4, then the desired separator can be obtained by setting Q=Lh and P=.

In the remaining case, Vm=i=+1h1Li has weight at least W/2. Let Vin,Vout be the set of vertices in Vm that are strictly inside or outside C, respectively. Without loss of generality, say Vin has weight at least W/4. Recall that Vin has weight at most 3W/4 by definition of C. Let Pu (resp. Pv) be the portion of the shortest path from x to u (resp. v) with levels between and h. Then Pu and Pv are paths of length O(p). The desired separator can be obtained by setting P=PuPv and Q=LLh. See Figure 2.

Finally, we consider the general case when G may have multiple connected components. If all components have weight at most W/2, a trivial separator exists with S=. On the other hand, if G has one component of weight at least W/2, we can apply the lemma to the largest-weight component and add the remaining components to the smaller of the two subsets V1,V2 in terms of weight (which would still have total weight at most 3W/4).

Figure 2: Proof of Lemma 2. Solid curves consist of edges in G, whereas dashed curves may contain edges in the triangulation but not in G.

2.3 Ensuring simplicity of walks

In this subsection, we formulate a type of legal alternating closed walks so that a shortest closed walk of this type is automatically a simple cycle. This will be useful later in Section 4. (Warning: both the formulation and the proof of correctness below are somewhat subtle.)

In the following, we imagine that a separator has been computed, and the two parts are colored red and blue, while the separator vertices are colored white.

Lemma 3.

Let G be an undirected graph, where each vertex is colored red, blue, or white, and there are no edges between red and blue vertices. Consider a closed walk C which is the concatenation of simple paths π0R,τ0,π0B,τ0,,πk1R,τk1,πk1B,τk1 with k1, where each πiR consists of red and white vertices only and has at least one red vertex, each πiB consists of blue and white vertices only and has at least one blue vertex, and each τi and τi consist of white vertices only (but may be empty). Then C must contain a nontrivial simple cycle.

Proof.

Suppose that two consecutive edges of C are identical, i.e., we see 3 consecutive vertices u,v,u in C. If uv is the last edge of πiR and vu is the first edge of τi, then u and v are white vertices and we can remove v from C and still have a closed walk satisfying the stated condition. If uv is the last edge of πiR, and τi is empty, and vu is the first edge of πiB, then u and v must again be white vertices and we can remove v from C and still have a closed walk satisfying the stated condition. After handling all other similar cases, we may assume that no two consecutive edges of C are identical. Now, C forms a subgraph where every vertex has degree at least 2, and so must contain a nontrivial simple cycle.

Lemma 4.

Let G be an undirected graph, where each vertex is colored red, blue, or white, and there are no edges between red and blue vertices. Let R, B, and W be the subset of red, blue, and white vertices respectively. Define the following:

  • A simple path π from u to v in G is a legal red path if π lies in G[RW], u,vW, and δG[RW](u,v)δG[W](u,v).

  • A simple path π from u to v in G is a legal blue path if π lies in G[BW], u,vW, and δG[BW](u,v)δG[W](u,v).

  • A closed walk C is a legal alternating walk if it is the concatenation of simple paths π0R,τ0,π0B,τ0, ,πk1R,τk1,πk1B,τk1 with k1, where each πiR is a legal red path, each πiB is a legal blue path, and each τi and τi lie in G[W].

Then

  1. (i)

    the girth of G is at most the length of a shortest legal alternating closed walk;

  2. (ii)

    furthermore, equality holds if the girth of G is not equal of girth of G[RW] or the girth of G[BW].

Proof.

For (i), consider a shortest legal alternating closed walk C. Then C is the concatenation of simple paths π0R,τ0,π0B,τ0,,πk1R,τk1,πk1B,τk1 with k1, where each πiR is a legal red path, each πiB is a legal blue path, and each τi and τi lie in G[W]. Each πiR must pass through at least one red vertex, because δG[RW](u(πiR),v(πiR))δG[W](u(πiR),v(πiR)), where u(π) and v(π) denote the starting and ending vertices of a path π. Similarly, each πiB must pass through at least one blue vertex. So, the condition in Lemma 3 is satisfied, and C must contain a nontrivial simple cycle. Hence, the girth of G is at most the length of C.

For (ii), consider a shortest simple cycle C in G, of length g. If there are multiple shortest simple cycles, pick one with the minimum number of non-white vertices. We can express C as a concatenation of simple paths π0R,π0B,,πk1R,πk1B with k1, where each πiR lies in G[RW], uses at least one red vertex, and starts and ends with white vertices, and each πiB lies in G[BW], uses at least one blue vertex, and starts and ends with white vertices. (Note that C contains at least one red and at least one blue vertex, by the assumption in stated in (ii).) If δG[RW](u(πiR),v(πiR))=δG[W](u(πiR),v(πiR)) for some i, then we can replace πiR with a shortest path γ from u(πiR) to v(πiR) in G[W], and obtain a closed walk which is the concatenation of two non-identical simple paths γ and CπiR, and so must contain a nontrivial simple cycle; the cycle has length at most g and uses fewer non-white vertices: a contradiction. Thus, each πiR is a legal red path. Similarly, each πiB is a legal blue path. Hence, C is a legal alternating closed walk.

(An astute reader might wonder why we have overcomplicated the definition of legal alternating walk by including the white subpaths τi, since part (ii) of the proof of Lemma 4 does not require them. The purpose for including them is computational, as we will see later: without them, intermediate distance matrices may no longer satisfy the bounded-difference property.)

3 Multiple Distances in Clustered Planar Graphs

As a warm-up, we first present an algorithm for a subproblem (of independent interest), on computing all distances with sources and destinations from a given subset X, in an intersection graph of line segments. It is actually more convenient to solve the problem for a more general family of graphs, which we call clustered planar graphs, where each vertex in a planar graph is replaced by a “cluster” of c vertices:

Definition 5.

A c-clustered planar graph refers to the product graph G^=G×Kc where G=(V,E) is a planar graph and Kc is the c-clique. In other words, the vertices of G^ are pairs (v,j)V×{1,,c}, and there is an edge between two vertices (u,i) and (v,j) whenever uvE or u=v.

Known shortest-path-related algorithms for planar graphs do not necessarily generalize to clustered planar graphs (because of the lack of Monge property, VC-dimension arguments, etc.). We prove the following result, which beats the obvious O~(xn) time bound, for example, when x is around n:

Theorem 6.

Let G^=G×Kc be a c-clustered planar graph, where G=(V,E) has n vertices and c=O(1). Suppose each edge of G^ has a nonnegative integer weight bounded by O(1). Given a subset X of x vertices in G, we can compute δG^[X×Kc,X×Kc] in O~(n3/2α+n(1/2+α)(3+ω)/2+x(3+ω)/2+x2n1/2α) expected time for any given α.

Proof.

We will solve an extended problem: given G, G^, X, and an additional subset B of β vertices in G such that B has γ components in G, we want to compute δG^[(BX)×Kc,(BX)×Kc]. (Initially, B= and β=γ=0.)

Step 1: Build a separator.

Give each vertex in VB weight 1 and each vertex in B weight 1+w for a parameter w (assuming n+wβ(1+w)/ε); the total weight is n+wβ. Give each vertex in VB load 1 and each vertex in B load n/β; the total load is O(n). We apply Lemma 2 for a value p to be set later, to partition V into V1,V2,S such that

  • |Vi|+w|ViB|3(n+wβ)/4 for each i{1,2};

  • there are no edges of G in V1×V2;

  • S can be further partitioned into P and Q such that P is the union of at most two paths in G of length O(p), and Q has total load at most O(n/p) – this implies that |Q|O(n/p) and |QB|O(n/pn/β)=O(β/p) simultaneously.

Let V^=V×Kc, S^=S×Kc, P^=P×Kc, Q^=Q×Kc, B^=B×Kc and X^=X×Kc.

Step 2: Recurse.

For each i{1,2}, we recursively solve the problem for Gi=G[ViS], G^i=Gi×Kc (with edge weights inherited from G^), Bi=(ViB)P(QB), and Xi=ViX.

Let ni=|ViS|, βi=|Bi|, γi be the number of components of Bi in Gi, and xi=|Xi|. Then n1+n2n+O(p+n/p), β1+β2β+O(p+β/p), ni+wβi3(n+wβ)/4+O(w(p+n/p)), and x1+x2x.

To bound γi, consider a component C of Bi in Gi. If C does not visit S, then C is an original component of B (since SBBi). If C visits a vertex of P, then C contains one of the two paths in P (since PBi). If C visits a vertex of QB, then C can be charged to that vertex. It follows that γ1+γ2γ+O(1+β/p).

Step 3: Compute 𝜹𝑮^[𝑩^𝑿^,𝑩^𝑿^].

We now compute δG^[B^X^,B^X^] by the following expression:

δG^1[B^X^,B^X^]δG^2[B^X^,B^X^] (1)
(δG^[B^X^,Q^]δG^[Q^,B^X^]) (2)
((δG^1[B^X^,P^]δG^2[B^X^,P^])(δG^1[P^,P^]δG^2[P^,P^])n
(δG^1[P^,B^X^]δG^2[P^,B^X^])), (3)

where MM denotes the entry-wise minimum of two matrices M and M, and Mk denotes the k-th power under min-plus product.

The expression is correct because for u^,v^B^X^, if a shortest path π from u^ to v^ in G^ avoids S^, then its length is δG^1(u^,v^) or δG^2(u^,v^); otherwise, if π passes through Q^, then its length is (δG^[B^X^,Q^]δG^[Q^,B^X^])(u^,v^); otherwise, if π passes through P^, starting from G^i and ending in G^j, then its length is (δG^1[B^X^,P^](δG^1[P^,P^]δG^2[P^,P^])nδG^j[P^,B^X^])(u^,v^).

To evaluate the expression, we first compute δG^[V^,Q^] and δG^i[V^,Q^] for each i{1,2} by running BFS from each vertex of Q^. Since |Q|=O(n/p), this part takes O~(n2/p) time.

The matrix δG^i[B^X^,B^X^] is available, since (BX)(ViS)BiXiQ, and we know δG^i[B^iX^i,B^iX^i] from the two recursive calls, and we already know δG^i[V^,Q^].

The matrices δG^i[B^X^,P^] and δG^i[P^,P^] are also available, since PBi.

We now describe how to compute δG^[B^X^,Q^]δG^[Q^,B^X^] in (2). For any component C^B^, the columns of δG^[C^,Q^] satisfy the bounded-difference property, after reordering the rows according to an Euler tour of a spanning tree of C – some rows may need to be duplicated, but the number of rows increases by only a constant factor. (Note that all vertices in a common cluster {v}×Kc are within a constant distance from each other.) Since B has γ components, we can compute δG^[B^,Q^]δG^[Q^,B^X^] by Lemma 1 in O~(γ(β+n/p+x)(3+ω)/2) time. The product δG^[B^X^,Q^]δG^[Q^,B^] is symmetric. It remains to compute δG^[X^,Q^]δG^[Q^,X^]: here, since we don’t have the bounded-difference property, we naively compute the product in O(|X|2|Q|)=O(x2n/p) time.

Finally, we describe how to compute (3). The columns of δG^i[P^,P^] satisfy the bounded-difference property, after dividing the matrix into two parts and reordering the rows, since P is the union of at most two walks; so, we can compute δG^1[P^,P^]δG^2[P^,P^] in O~(p(3+ω)/2) time. We can compute the n-th power by repeated squaring using O(logn) bounded-difference matrix products. (Note that if the columns of a matrix M satisfy the bounded-difference property, then the columns of a product MM also satisfy the bounded-difference property.)

The rows of δG^i[B^X^,P^] satisfy the bounded-difference property (after dividing the matrix into two parts), and so the other products can be computed in a similar way.

Running time.

The time complexity T(n,β,γ,x) of the algorithm satisfies the following recurrence:

T(n,β,γ,x)maxn1,n2,β1,β2,x1,x2:ni+wβi3(n+wβ)/4+O(w(p+n/p)),n1+n2n+O(p+n/p),β1+β2β+O(p+β/p),γ1+γ2γ+O(1+β/p),x1+x2x(T(n1,β1,γ1,x1)+T(n2,β2,γ2,x2)+O~(n+n2/p+γ(β+p+n/p+x)(3+ω)/2+x2n/p)).

Solving the recurrence.

Intuitively, one could choose pn1/2+α, and think of β as O~(p) and γ as O~(1), and see that the cost is upper bounded by n3/2α+x(3+ω)/2+x2n1/2α for any sufficiently small positive α (as long as ω<3), at least at the top few levels of the recursion.

Formally, let r be a fixed parameter, to be set later, with rw(p+n/p)logn. For a node u in the recursion tree, let nu,βu,γu,Xu denote its input parameters. Suppose we stop the recursion at a node u whenever nu+wβur; in particular, this condition implies nur and βur/w simultaneously. Then the parent v of each leaf satisfies μv+wβv>r. This recursion subtree has depth at most O(logn+wβr). Let ξ be the size of this recursion subtree. Then v(nv+wβv)O((n+wβ+ξw(p+n/p))logn+wβr), where the summation is over each v that is the parent of some leaf. Thus, ξO(1rv(nv+wβv))O(n+wβrlogn+wβr)+o(ξ), implying that ξO(n+wβrlogn+wβr).

This leads to a new recurrence:

T(n,β,γ,x)maxx1,x2,:kxkxk=1O(n+wβrlogn+wβr)(T(r,r/w,γ+O~(1+β/p),xk)+O~(n+n2/p+γ(β+p+n/p+x)(3+ω)/2+x2n/p)).

We now set β=n1/2+α, w=n1/2α, r=n/t, and p=n1/2+α/log1+εn for a sufficiently large constant t. Note that indeed rw(p+n/p)logn. By loosely bounding r/w by (n/t)1/2+α, the recurrence becomes:

T(n,n1/2+α,γ,x)maxx1,x2,:kxkxk=1O(tlogt)(T(n/t,(n/t)1/2+α,γ+O~(1),xk)+O~(n3/2α+γ(n(1/2+α)(3+ω)/2+x(3+ω)/2)x2n1/2α)).

This solves to T(n,n1/2+α,γ,x)=O~(n3/2α+(1+γ)(n(1/2+α)(3+ω)/2+x(3+ω)/2)+x2n1/2α).

Corollary 7.

Given a set A of line segments in 2 and a subset XA of x segments, we can compute δG[X,X], where G is the intersection graph of A, in O~(μ3/2α+μ(1/2+α)(3+ω)/2+x(3+ω)/2+x2μ1/2α) expected time for any given α, where μ is the number of endpoints and intersection points of A.

Proof.

For simplicity, we assume that the given segments are in general position (e.g., no 3 segments intersect at a common point).

First we compute the intersections of the line segments in A, for example, by applying Bentley and Ottmann’s plane-sweep algorithm [4], which runs in O(μlogμ) time.

Let H be the planarized intersection graph of A, i.e., the planar graph formed by the arrangement of A, where the vertices consist of the segment endpoints and intersection points of A, and the edges of H correspond to pairs of adjacent vertices in the arrangement.

Let H^ be the clustered planar graph H×K4 (see Figure 3). Number the edges incident to each vertex of H from {1,2,3,4} in clockwise order. Give the edge (u,i)(v,j) weight 0 in H^ if uv is in H and the i-th edge incident to u coincides with the j-th edge incident to v. In addition, for each vertex u of degree 4 in H, give the edges (u,1)(u,2), (u,2)(u,3), (u,3)(u,4), (u,4)(u,1) weight 1, and give the edges (u,1)(u,3) and (u,2)(u,4) weight 0. Give all other edges weight 2 in H^. Let u(s) denote the left endpoint of a segment s. Then for any two segments s and t, the distance between s and t in G is equal to the distance between (u(s),1) and (u(t),1) in H^. So, the result immediately follows by applying Theorem 6 to H^ and {u(s):sX}.

Figure 3: The clustered planar graph H^. The dotted edges and the dashed edges have weight 0, while the solid edges have weight 1. Edges with weight 2 are omitted.

4 Girth for Line Segments

We now present our girth algorithm for intersection graphs of line segments. It is tempting to continue to work within the clustered planar graph framework, but unfortunately a clustered planar graph by definition contains short cycles in every cluster (furthermore, when generalizing from segments to curves later, an additional difficulty is that simple cycles in the planarized intersection graph may not correspond to simple cycles in the intersection graph – see Figure 4).

We propose another recursive algorithm, which is also based on our separator lemma but proceeds differently: on one hand, we have to work with intersection graphs instead of clustered planar graphs, and also have to deal with the issue of ensuring simplicity of walks; on the other hand, Corollary 7 is available as a subroutine to compute distances, so fewer input arguments are needed in the new recursive algorithm (notably, we don’t need an additional input set B).

Figure 4: These are not simple cycles in the intersection graph!
Theorem 8.

Given a set A of n line segments in 2, we can compute the girth gG of its intersection graph G of A in O(n1.483) expected time, under the promise that the girth is more than 4.

Proof.

It is known that any intersection graph of n line segments with girth more than 4 must have O(n) edges [42].

Step 1: Build a separator.

We first construct the planarized intersection graph H=(VH,EH), as in the proof of Corollary 7, in O~(n) time. Note that μ=|VH|=O(n). Define the weight of a point pVH to be 1 if it is the left endpoint of a segment, and 0 otherwise; the total weight is n. We can apply Lemma 2 (with unit loads), for a value p to be set later, to partition VH into V1,V2,SH such that

  • Vi has weight at most 3n/4 for each i{1,2};

  • there are no edges of H in V1×V2;

  • SH can be further partitioned into PH and QH such that PH is the union of at most two paths in H of length O(p), and |QH|=O(n/p).

For each i{1,2}, let Ai consist of the segments sA for which all points of VH on s are in Vi. Note that |Ai|3n/4. Let P consist of the segments with at least one point in PH. Let Q consist of the segments with at least one point in QH and no points in PH. Let S=PQ. Note that P is the union of at most two walks of length O(p) in G (since any path in H corresponds to a walk in G).

Step 2: Recurse.

For each i{1,2}, we recursively solve the problem for AiP to obtain the girth gGi of the intersection graph Gi of AiP. (Note that the assumption that G has girth more than 4 implies that Gi also has girth more than 4.)

Let ni=|AiP|. Then n1,n23n/4+O(p) and n1+n2n+O(p).

Step 3: Compute 𝜹𝑮𝒊[𝑷,𝑷].

For each i{1,2}, we compute δGi[P,P] by Corollary 7 in O~(n3/2α+n(1/2+α)(3+ω)/2+p(3+ω)/2+p2n1/2α) expected time.

Step 4: Compute the girth 𝒈𝑮.

We first run BFS from each segment of Q to find the length gQ of the shortest cycle visiting Q in G. This part takes O~(n2/p) time.

Next, we compute the length glegal of the shortest legal alternating closed walk where the segments in A1 are red, the segments in A2 are blue, and the segments in P are white (discarding the segments in Q). By Lemma 4, the girth gG[A1A2P] of G[A1A2P] is equal to min{glegal,gG1,gG2}. The final answer is gG=min{gG[A1A2P],gQ}.

To compute glegal, for each i{1,2}, we first compute the “legal” distance matrices δGi[P,P]: for u,vP, let

δGi(u,v)={δGi(u,v)if δGi(u,v)δG[P](u,v),+otherwise.

We already know the matrix δGi[P,P]. We can compute δG[P] naively in O~(pω) time. Consequently, we know the matrix δGi[P,P].

Next, we compute

δGi′′[P,P]=δGi[P,P]δG[P].

Although δGi[P,P] may not satisfy a bounded-difference property, the rows of δG[P] satisfy the bounded-difference property, after dividing the matrix into two parts and reordering the columns, since P is the union of at most two walks. So, we can compute δGi′′[P,P] in O~(p(3+ω)/2) time by Lemma 1. It also follows that the rows of δGi′′[P,P] satisfy the bounded-difference property. Finally, let

Zk=i=1k(δG1′′[P,P]δG2′′[P,P])i.

From the definition of legal alternating walks, we see that Zn(u,u) is precisely the length of the shortest legal alternating closed walk starting at uP. Thus, glegal is the smallest diagonal entry in Zn. We can compute Zn recursively by the following formula:

Zk=(Zk/2Zk/2)(δG1′′[P,P]δG2′′[P,P]).

(This assumes that k is even, and the odd case is similar.) This requires O(logn) min-plus matrix products, and all intermediate matrices satisfy the bounded-difference property. So, Zn can be computed in O~(p(3+ω)/2) time.

Running time.

The time complexity T(n) of the algorithm satisfies the following recurrence:

T(n)maxn1,n2:n1,n23n/4+O(p),n1+n2n+O(p)(T(n1)+T(n2)+O~(n2/p+n3/2α+n(1/2+α)(3+ω)/2+p(3+ω)/2+p2n1/2α)).

To balance the three terms n2/p, n(1/2+α)(3+ω)/2, and p2n1/2α, we set p=n1/2+ρ and α=3ρ, with ρ=3ω22+6ω>0.0173, using the latest bound ω<2.371339 [2]. Then the recurrence becomes:

T(n)maxn1,n2:n1,n23n/4+o(n),n1+n2n+o(n)(T(n1)+T(n2)+O~(n3/2ρ)),

which solves to T(n)=O~(n3/2ρ)O(n1.483).

Finally, we remove the assumption that girth is more than 4:

Corollary 9.

Given n line segments in 2, we can compute the girth of the intersection graph in O(n1.483) expected time.

Proof.

We can check whether the intersection graph G contains a 3-cycle in O(n1.408) time by an algorithm of Chan [14, Theorem 5.1], or a 4-cycle in O~(n) time by another algorithm of Chan [14, Theorem 6.2]. So, we may assume that the girth is greater than 4, and the result follows from Theorem 8.

In the full version, we describe how to modify our algorithms more generally for arbitrary algebraic curves or semialgebraic sets that are connected and have constant description complexity.

Our results are unlikely to be optimal. Although we do not know how to improve Corollary 7, we are currently working on ideas that might further improve the time bound of Corollary 9 for the case of line segments, by exploiting special properties about intersection graphs with large girth.

References

  • [1] Pankaj K. Agarwal and Marc J. van Kreveld. Connected component and simple polygon intersection searching. Algorithmica, 15(6):626–660, 1996. doi:10.1007/BF01940884.
  • [2] Josh Alman, Ran Duan, Virginia Vassilevska Williams, Yinzhan Xu, Zixuan Xu, and Renfei Zhou. More asymmetry yields faster matrix multiplication. In Proc. 36th ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 2005–2039, 2025. doi:10.1137/1.9781611978322.63.
  • [3] Noga Alon, Raphael Yuster, and Uri Zwick. Color-coding. J. ACM, 42(4):844–856, 1995. doi:10.1145/210332.210337.
  • [4] Jon Louis Bentley and Thomas Ottmann. Algorithms for reporting and counting geometric intersections. IEEE Trans. Computers, 28(9):643–647, 1979. doi:10.1109/TC.1979.1675432.
  • [5] Béla Bollobás. Chromatic number, girth and maximal degree. Discret. Math., 24(3):311–314, 1978. doi:10.1016/0012-365X(78)90102-4.
  • [6] Édouard Bonnet, Sergio Cabello, and Wolfgang Mulzer. Maximum matchings in geometric intersection graphs. Discret. Comput. Geom., 70(3):550–579, 2023. doi:10.1007/S00454-023-00564-3.
  • [7] Karl Bringmann and Alejandro Cassis. Faster knapsack algorithms via bounded monotone min-plus-convolution. In Proc. 49th International Colloquium on Automata, Languages, and Programming (ICALP), volume 229 of LIPIcs, pages 31:1–31:21, 2022. doi:10.4230/LIPIcs.ICALP.2022.31.
  • [8] Karl Bringmann, Anita Dürr, and Adam Polak. Even faster knapsack via rectangular monotone min-plus convolution and balancing. In Proc. 32nd European Symposium on Algorithms (ESA), volume 308 of LIPIcs, pages 33:1–33:15, 2024. doi:10.4230/LIPIcs.ESA.2024.33.
  • [9] Karl Bringmann, Fabrizio Grandoni, Barna Saha, and Virginia Vassilevska Williams. Truly subcubic algorithms for language edit distance and RNA folding via fast bounded-difference min-plus product. SIAM J. Comput., 48(2):481–512, 2019. doi:10.1137/17M112720X.
  • [10] Karl Bringmann, Sándor Kisfaludi-Bak, Marvin Künnemann, André Nusser, and Zahra Parsaeian. Towards sub-quadratic diameter computation in geometric intersection graphs. In Proc. 38th International Symposium on Computational Geometry (SoCG), volume 224 of LIPIcs, pages 21:1–21:16, 2022. doi:10.4230/LIPIcs.SOCG.2022.21.
  • [11] Sergio Cabello. Subquadratic algorithms for the diameter and the sum of pairwise distances in planar graphs. ACM Trans. Algorithms, 15(2):21:1–21:38, 2019. doi:10.1145/3218821.
  • [12] Sergio Cabello and Wolfgang Mulzer. Minimum cuts in geometric intersection graphs. Comput. Geom., 94:101720, 2021. doi:10.1016/J.COMGEO.2020.101720.
  • [13] Parinya Chalermsook, Jittat Fakcharoenphol, and Danupon Nanongkai. A deterministic near-linear time algorithm for finding minimum cuts in planar graphs. In Proc. 15th ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 828–829, 2004. doi:10.5555/982792.982916.
  • [14] Timothy M. Chan. Finding triangles and other small subgraphs in geometric intersection graphs. In Proc. 34th ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1777–1805, 2023. doi:10.1137/1.9781611977554.CH68.
  • [15] Timothy M. Chan, Hsien-Chih Chang, Jie Gao, Sándor Kisfaludi-Bak, Hung Le, and Da Wei Zheng. Truly subquadratic time algorithms for diameter and related problems in graphs of bounded VC-dimension. CoRR, abs/2510.16346, 2025. To appear in FOCS 2025. doi:10.48550/arXiv.2510.16346.
  • [16] Timothy M. Chan and Moshe Lewenstein. Clustered integer 3SUM via additive combinatorics. In Proc. 47th ACM Symposium on Theory of Computing (STOC), pages 31–40, 2015. doi:10.1145/2746539.2746568.
  • [17] Timothy M. Chan and Dimitrios Skrepetos. All-pairs shortest paths in geometric intersection graphs. J. Comput. Geom., 10(1):27–41, 2019. doi:10.20382/JOCG.V10I1A2.
  • [18] L. Sunil Chandran and C. R. Subramanian. Girth and treewidth. J. Comb. Theory B, 93(1):23–32, 2005. doi:10.1016/J.JCTB.2004.05.004.
  • [19] Hsien-Chih Chang and Hsueh-I Lu. Computing the girth of a planar graph in linear time. SIAM J. Comput., 42(3):1077–1094, 2013. doi:10.1137/110832033.
  • [20] Shucheng Chi, Ran Duan, and Tianle Xie. Faster algorithms for bounded-difference min-plus product. In Proc. 33th ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1435–1447, 2022. doi:10.1137/1.9781611977073.60.
  • [21] Shucheng Chi, Ran Duan, Tianle Xie, and Tianyi Zhang. Faster min-plus product for monotone instances. In Proc. 54th ACM Symposium on Theory of Computing (STOC), pages 1529–1542, 2022. doi:10.1145/3519935.3520057.
  • [22] R. J. Cook. Chromatic number and girth. Periodica Mathematica Hungarica, 6(1):103–107, 1975. doi:10.1007/BF02018401.
  • [23] Reinhard Diestel. Graph Theory, volume 173 of Graduate texts in mathematics. Springer, 2015. doi:10.1007/978-3-662-70107-2.
  • [24] Hristo N. Djidjev. Computing the girth of a planar graph. In Proc. 27th International Colloquium on Automata, Languages and Programming (ICALP), volume 1853 of LIPIcs, pages 821–831, 2000. doi:10.1007/3-540-45022-X_69.
  • [25] Hristo N. Djidjev. A faster algorithm for computing the girth of planar and bounded genus graphs. ACM Trans. Algorithms, 7(1):3:1–3:16, 2010. doi:10.1145/1868237.1868240.
  • [26] Guillaume Ducoffe, Michel Habib, and Laurent Viennot. Diameter, eccentricities and distance oracle computations on H-minor free graphs and graphs of bounded (distance) Vapnik-Chervonenkis dimension. SIAM J. Comput., 51(5):1506–1534, 2022. doi:10.1137/20M136551X.
  • [27] Paul Erdös. Graph theory and probability. Canadian Journal of Mathematics, 11:34–38, 1959. doi:10.1007/978-0-8176-4842-8_19.
  • [28] Jeff Erickson. Planar separators. Notes, 2023. URL: https://jeffe.cs.illinois.edu/teaching/comptop/2023/notes/14-planar-separators.pdf.
  • [29] Jittat Fakcharoenphol and Satish Rao. Planar graphs, negative weight edges, shortest paths, and near linear time. J. Comput. Syst. Sci., 72(5):868–889, 2006. doi:10.1016/J.JCSS.2005.05.007.
  • [30] Pawel Gawrychowski, Haim Kaplan, Shay Mozes, Micha Sharir, and Oren Weimann. Voronoi diagrams on planar graphs, and computing the diameter in deterministic O~(n5/3) time. SIAM J. Comput., 50(2):509–554, 2021. doi:10.1137/18M1193402.
  • [31] Yuzhou Gu, Adam Polak, Virginia Vassilevska Williams, and Yinzhan Xu. Faster monotone min-plus product, range mode, and single source replacement paths. In Proc. 48th International Colloquium on Automata, Languages, and Programming (ICALP), volume 198 of LIPIcs, pages 75:1–75:20, 2021. doi:10.4230/LIPIcs.ICALP.2021.75.
  • [32] Alon Itai and Michael Rodeh. Finding a minimum circuit in a graph. SIAM J. Comput., 7(4):413–423, 1978. doi:10.1137/0207033.
  • [33] Haim Kaplan, Katharina Klost, Wolfgang Mulzer, Liam Roditty, Paul Seiferth, and Micha Sharir. Triangles and girth in disk graphs and transmission graphs. In Proc. 27th European Symposium on Algorithms (ESA), volume 144 of LIPIcs, pages 64:1–64:14, 2019. doi:10.4230/LIPIcs.ESA.2019.64.
  • [34] Philip Klein and Shay Mozes. Optimization algorithms for planar graphs. Book draft, 2024. URL: https://planarity.org.
  • [35] Katharina Klost and Wolfgang Mulzer. Robust algorithms for finding triangles and computing the girth in unit disk and transmission graphs. CoRR, abs/2405.01180, 2024. doi:10.48550/arXiv.2405.01180.
  • [36] Hung Le and Christian Wulff-Nilsen. VC set systems in minor-free (di)graphs and applications. In Proc. 35th ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 5332–5360, 2024. doi:10.1137/1.9781611977912.192.
  • [37] Jason Li and Merav Parter. Planar diameter via metric compression. In Proc. 51st ACM Symposium on Theory of Computing (STOC), pages 152–163, 2019. doi:10.1145/3313276.3316358.
  • [38] Richard J. Lipton and Robert Endre Tarjan. A separator theorem for planar graphs. SIAM Journal of Applied Mathematics, 36(2):177–189, 1979. doi:10.1137/0136016.
  • [39] László Lovász. On chromatic number of finite set-systems. Acta Mathematica Academiae Scientiarum Hungarica, 19(1):59–67, 1968. doi:10.1007/BF01894680.
  • [40] Xiao Mao. Breaking the cubic barrier for (unweighted) tree edit distance. In Proc. 62nd IEEE Symposium on Foundations of Computer Science (FOCS), pages 792–803, 2021. doi:10.1109/FOCS52979.2021.00082.
  • [41] Gary L. Miller. Finding small simple cycle separators for 2-connected planar graphs. J. Comput. Syst. Sci., 32(3):265–279, 1986. doi:10.1016/0022-0000(86)90030-9.
  • [42] János Pach and Micha Sharir. On planar intersection graphs with forbidden subgraphs. J. Graph Theory, 59(3):205–214, 2008. doi:10.1002/JGT.20332.
  • [43] Barna Saha and Christopher Ye. Faster approximate all pairs shortest paths. In Proc. 35th ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 4758–4827, 2024. doi:10.1137/1.9781611977912.170.
  • [44] Jeffrey D. Ullman and Mihalis Yannakakis. High-probability parallel transitive-closure algorithms. SIAM J. Comput., 20(1):100–125, 1991. doi:10.1137/0220006.
  • [45] Virginia Vassilevska Williams. On some fine-grained questions in algorithms and complexity. In Proc. International Congress of Mathematicians (ICM), pages 3447–3487, 2018. doi:10.1142/9789813272880_0188.
  • [46] Oren Weimann and Raphael Yuster. Computing the girth of a planar graph in O(nlogn) time. SIAM J. Discret. Math., 24(2):609–616, 2010. doi:10.1137/090767868.
  • [47] Uri Zwick. All pairs shortest paths using bridging sets and rectangular matrix multiplication. J. ACM, 49(3):289–317, 2002. doi:10.1145/567112.567114.