Faster, Deterministic and Space Efficient Subtrajectory Clustering
Abstract
Given a trajectory and a distance , we wish to find a set of curves of complexity at most , such that we can cover with subcurves that each are within Fréchet distance to at least one curve in . We call an -clustering and aim to find an -clustering of minimum cardinality. This problem variant was introduced by Akitaya et al. (2021) and shown to be NP-complete. The main focus has therefore been on bicriteria approximation algorithms, allowing for the clustering to be an -clustering of roughly optimal size.
We present algorithms that construct -clusterings of size, where is the size of the optimal -clustering. We use space and time. Our algorithms significantly improve upon the clustering quality (improving the approximation factor in ) and size (whenever ). We offer deterministic running times improving known expected bounds by a factor near-linear in . Additionally, we match the space usage of prior work, and improve it substantially, by a factor super-linear in , when compared to deterministic results.
Keywords and phrases:
Fréchet distance, clustering, set coverCategory:
Track A: Algorithms, Complexity and GamesFunding:
Ivor van der Hoog: This project has received funding from the European Union’s Horizon 2020 research and innovation programme under the Marie Skłodowska-Curie grant agreement No 899987, and from the Carlsberg Foundation via Eva Rotenberg’s Young Researcher Fellowship CF21-0302 “Graph Algorithms with Geometric Applications”.Copyright and License:
![[Uncaptioned image]](x1.png)
2012 ACM Subject Classification:
Theory of computation Computational geometryAcknowledgements:
We thank Jacobus Conradi for pointing out an error in a preprint of this paper.Editors:
Keren Censor-Hillel, Fabrizio Grandoni, Joël Ouaknine, and Gabriele PuppisSeries and Publisher:

1 Introduction
In subtrajectory clustering, the goal is to partition an input trajectory with vertices into subtrajectories and group them into clusters such that all subtrajectories within a cluster have low Fréchet distance to one another. Clustering under the Fréchet distance is a natural application of the Fréchet distance and a well-studied topic [15, 11, 10, 9, 16] with applications in, for example, map reconstruction [6, 7]. In recent years, several variants of this algorithmic problem have been proposed [8, 1, 3, 5]. Regardless of the variant, the subtrajectory clustering problem has been shown to be NP-complete [8, 1, 3].
We focus on the problem variant proposed by Akitaya, Brüning, Chambers, and Driemel [3]. Given a trajectory and a distance , and some , they compute what we call an -clustering of . Each cluster is a set of subtrajectories together with a center curve (the “reference curve” ) of complexity at most . Each curve in a cluster must have Fréchet distance at most to the center and each point on must be present in at least one cluster. The goal is to compute an -clustering of minimum cardinality. Note that the parameter is necessary to not trivialize the problem. Indeed, if may have arbitrary complexity, then a trivial -clustering exists consisting of a single cluster where .
Akitaya et al. [3] propose a bicriteria approximation scheme: Given and , let be the minimum size of an -clustering of . The goal is to compute an -clustering of size . This paradigm was studied in [3, 5, 13] and previous results are summarised in Table 1. [3] computes an -clustering of size. The running time and space bounds depend on the arc length of relative to . Brüning, Conradi and Driemel[5] compute an -clustering of size (where the hidden constant is exceptionally large). Their algorithm uses space and has expected running time. Recently, Conradi and Driemel [13] improve both the size and the quality of the clustering. They compute an -clustering of size in space and time.
# Clusters | Time | Space | Source | |
---|---|---|---|---|
[3] | ||||
[5] | ||||
[13] | ||||
Thm. 16 |
Results.
We present a bicriteria approximation algorithm that uses time and space, and computes an -clustering of size . When compared to previous works [3, 13, 5] our results:
-
obtain deterministic results and improve the running time by a factor near-linear in ,
-
match the space usage,
-
improve the approximation in from a factor to ,
-
asymptotically match the clustering size (whenever ).
Compared exclusively to deterministic results [13], we instead improve time by a factor near-linear in , space by a factor super-linear in , and obtain asymptotically equal clustering size for all (see also Table 1).
Methodology and contribution.
Our algorithm constructs a clustering iteratively by greedily adding a cluster that covers an approximately-maximum set of uncovered points on . The challenge is to compute such a cluster. Previous work [5, 3] presented randomized algorithms for constructing a cluster based on -net sampling over the set of all candidate clusters. They shatter the set of candidate clusters and show that it has bounded VC dimension, which leads to their asymptotic approximation of – the minimum size of an -clustering. The algorithm of Conradi and Driemel [13] is more similar to ours. They also simplify the input and iteratively select the cluster with the (exact) maximum coverage to obtain an -clustering of size . The key difference lies in finding the next cluster. Conradi and Driemel [13] explicitly consider a set of candidate clusters, which requires time and space to construct.
We make two key contributions that distinguish us from prior works: First, we present a novel simplification algorithm that computes a curve such that we may restrict potential reference curves of clusters to be subcurves of . This new curve simplification technique allows us to create a clustering where clusters have radius at most as opposed to . Second, we prove that we may restrict the reference curves to be one of two types:
-
vertex-subcurves of , which are subcurves that start and end at a vertex of ,
(we may furthermore only consider subcurves whose complexity is a power of ) -
and subedges of , which are subcurves that are a subsegment of a single edge of .
We prove that a greedy algorithm that exclusively adds maximal clusters where the reference curve is of one of these two types creates a clustering of size . This characterization reduces the set of candidate clusters from to which significantly reduces the time spent compared to [13]. The geometric characterization of these subcurves allow us to compute candidate clusters on the fly, significantly reducing space usage.
2 Preliminaries
A (polygonal) curve with vertices is a piecewise-linear map whose breakpoints (called vertices) are at each integer parameter, and whose pieces are called edges. We denote by the subcurve of that starts at and ends at . If and are integers, we call a vertex subcurve of . Let denote the number of vertices of .
Fréchet distance.
A reparameterization of is a non-decreasing surjection . Two reparameterizations and of and , respectively, describe a matching between two curves and with and vertices, where for any , point is matched to . A matching is said to have cost where denotes the Euclidean norm. A matching with cost at most is called a -matching. The (continuous) Fréchet distance between and is the minimum cost over all matchings.
Free space diagram.
The parameter space of curves and with and vertices, respectively, is given by the orthogonal rectangle . This parameter space is associated with a regular grid whose cells are the squares for integers and . A point in the parameter space corresponds to the pair of points and . We say that is -free if . The -free space diagram of and is the set of -free points in the parameter space of and . The obstacles of are the connected components of .
Alt and Godau [4] observe that the Fréchet distance between and is at most if and only if there is a bimonotone path in from to (and and ).
Input and output.
Our input is a curve with vertices, which we will call the trajectory, some integer parameter , and some distance parameter . We consider clustering subtrajectories of using pathlets:
Definition 1 (Pathlet).
An -pathlet is a tuple where is a curve with and is a set of intervals in , where for all . We call the reference curve of .
We can see a pathlet as a cluster, where the center is and all subtrajectories induced by get mapped to . See Figure 1. An -clustering of is defined as follows:
Definition 2.
An -clustering is a set of -pathlets with .
Throughout this paper, we let denote the smallest integer for which there exists an -clustering of size . The goal is to find an -clustering where is not too large compared to , and .
Weighting a cluster.
We define a Universe as any set of interior-disjoint closed intervals that together cover . Given a fixed universe , we can weigh each pathlet by what we call its coverage:
Definition 3.
The coverage over of a pathlet is . The coverage of a set of pathlets is .
Whenever is clear from context we denote the coverage of a pathlet by .
Definition 4 (Reference optimal).
Let the universe be fixed and let be a set of -pathlets. An -pathlet is reference-optimal if its coverage over , i.e., , is maximum over all -pathlets with the same reference curve.
Definition 5.
Let the universe be fixed and let be a set of -pathlets. An -pathlet is optimal whenever is maximum over all -pathlets.
3 Algorithmic outline
Our algorithmic input is a trajectory , an integer , and value . We provide a high-level overview of our algorithm here. Our approach can be decomposed as follows:
-
1.
Reference curves may lie anywhere in the ambient space. Our first step is to restrict where these reference curves may lie. In Section 4 we construct a -simplification of , and prove that for any -pathlet , there exists a subcurve of for which is an -pathlet, where . Hence we may restrict our attention to pathlets where the reference curve is a subcurve of , if we allow for a slightly higher complexity. This higher complexity is circumvented later on, to still give an -clustering.
-
2.
In Section 5, Given and , we smartly create some universe . We prove, by adapting the argument for greedy set cover, that any algorithm that iteratively computes an optimal -pathlet outputs a clustering of size .
-
3.
In Section 6 we give the general algorithm. We choose some . We iteratively construct an -clustering of size . Our greedy iterative algorithm maintains a set of pathlets and adds an -pathlet to at every iteration.
Consider having a set of pathlets . We greedily select a pathlet that covers as much of as possible, and add it to . Formally, we select a -maximal -pathlet: an -pathlet such that
for all -pathlets .
-
4.
The subsequent goal is to compute -maximal pathlets. We restrict pathlets to two types: those where the reference curve is 1) a vertex subcurve of , or 2) a subsegment of an edge of . Then we give algorithms for constructing pathlets of these types with a certain quality guarantee, i.e., pathlets that cover at least a constant fraction of what the optimal pathlet of that type covers. These algorithms are given in Sections 8 and 9.
Reachability graph.
We introduce the reachability graph in Section 7. This graph is defined on a subcurve of and a set of points in . The reachability graph is a directed acyclic graph whose vertices are the set of points , together with certain boundary points of the free space and a collection of steiner points. Given two points and in , the graph contains a directed path from to if and only if .
We treat the free space diagram as a rectilinear polygon with rectilinear holes, obtained by reducing all obstacles of to their intersections with the parameter space grid. We show that a bimonotone path between two points and exists in if and only if a rectilinear shortest path between and in has length , the -distance between and . The reachability graph is defined as the shortest paths preserving graph [20] for the set with respect to , made into a directed graph by directing edges, which are all horizontal or vertical, to the right or top. This graph has complexity, and a shortest path in the graph between points in is also a rectilinear shortest path between the corresponding points in .
Vertex-to-vertex pathlets.
In Section 8 we construct a pathlet where the reference curve is a vertex subcurve of . For a given vertex of , we construct reference-optimal -pathlets for all . We first identify a set of critical points in . We show that for every reference curve , there is a reference-optimal -pathlet where for each interval , the points and are critical points. We construct the intervals through a sweepline algorithm over the reachability graph , which has complexity. Our sweepline computes, for all , a reference-optimal -pathlet by iterating over all in-edges to critical points in . Doing this for all (and remembering the optimum) thereby takes time and space.
Subedge pathlets.
In Section 9 we construct a pathlet where the reference curve is a subsegment of an edge of . For a given edge of , we again first identify a set of critical points in . However, rather than restricting the intervals in pathlets based on these critical points, we restrict the reference curves based on these critical points. Specifically, there are unique -coordinates of points in , which we order as . We show that by allowing for pathlets to use subsegments of the reversal of as reference curves, we may restrict reference curves to be of the form or to not lose much coverage. That is, the optimal -pathlet with such a reference curve covers at least one-fourth of what any other -pathlet using a subsegment of as a reference curve covers.
The remainder of our subedge pathlet construction algorithm follows the same procedure as for vertex-to-vertex pathlets, though with the following optimization. We consider every separately, for . However, rather than considering all reference curves , of which there are , we consider only reference curves. The main observation is that we may split a pathlet into two: and , for some . One of the two pathlets covers at least half of what covers, so an optimal -pathlet that is defined by critical points covers at least one-eighth of any other subedge -pathlet .
For every , we let be the subset of critical points with -coordinate equal to or for some . We construct the reachability graph , which has complexity. We then proceed as with the vertex-to-vertex pathlets, using a sweepline through the reachability graph. Doing this for all (and remembering the optimal pathlet) thereby takes total time and space. Taken over all edges of , we obtain a subedge pathlet in time and space.
4 Pathlet-preserving simplifications
We first aim to limit our attention to -pathlets whose reference curves are subcurves of some universal curve . This way, we may design an algorithm that considers all subcurves of , rather than all curves in . This has the additional benefit of allowing the use of the free space diagram to construct pathlets, as seen in Figure 2.
For any -pathlet there exists an -pathlet where is a subcurve of . Indeed, consider any interval and choose . However, restricting the subcurves of to have complexity at most may significantly reduce the maximum coverage, see for example Figure 3.
Instead of restricting pathlets to be subcurves of , we restrict them to be subcurves of a different curve . We enforce the following property:
Definition 6.
For a trajectory and value , a pathlet-preserving simplification is a curve together with a -matching , where for any subtrajectory of and all curves with , the subcurve matched to by has complexity .
Theorem 7.
Let be a pathlet-preserving simplification of . For any -pathlet , there exists a subcurve such that is an -pathlet.
Proof.
Consider any -pathlet and choose some interval . For all , via the triangle inequality, . Let be the subcurve of matched to by . Naturally, , and so by the triangle inequality . By the definition of a pathlet-preserving simplification, we obtain that for every curve with , we have . In particular, setting implies that . Thus is an -pathlet.
Prior simplifications.
The curve that we construct is a curve-restricted -simplification of ; a curve whose vertices lie on , where for every edge of we have . Various -simplification algorithms have been proposed [17, 2, 14, 19].
If is a curve in , Guibas et al. [17] provide an time algorithm that constructs a -simplification for which there is no -simplification with . Their algorithm is not efficient in higher dimensions however.
Agarwal et al. [2] also construct a -simplification of in time. This was applied by Akitaya et al. [3] for their subtrajectory clustering algorithm under the discrete Fréchet distance. The simplification has a similar guarantee as the simplification of [17]: there exists no vertex-restricted -simplification with . This guarantee is weaker than that of [17], as vertex-restricted simplifications are simplifications formed by taking a subsequence of vertices of as the vertices of the simplification. It can, however, be constructed efficiently in higher dimensions.
As we show in Figure 3, the complexity of a vertex-restricted -simplification can be arbitrarily bad compared to the (unrestricted) -simplification with minimum complexity. Brüning et al. [5] note that for the subtrajectory problem under the continuous Fréchet distance, one requires an -simplification whose complexity has guarantees with respect to the optimal (unrestricted) simplification. They present a -simplification (whose definition was inspired by de Berg, Gudmundsson and Cook [14]) with the following property: for any subcurve of within Fréchet distance of some line segment, there exists a subcurve of with complexity at most that has Fréchet distance at most to . Thus, there exists no -simplification with .
Our new curve simplification.
In Definition 6 we presented yet another curve simplification under the Fréchet distance for curves in . Our simplification has a stronger property than the one that is realized by Brüning et al. [5]: for any subcurve and any curve with , we require that there exists a subcurve with that has at most two more vertices than . This implies both the property of Brüning et al. [5] and ensures that no -simplification exists with .
In the full version of our paper we provide an efficient algorithm for constructing pathlet-preserving simplifications. The algorithm is an extension of the vertex-restricted simplification of Agarwal et al. [2] to construct a curve-restricted simplification instead. For this, we use the techniques of Guibas et al. [17] to quickly identify if an edge of is suitable to place a simplification vertex on. We combine this check with the algorithm of [2] and obtain:
Theorem 8.
For any trajectory with vertices and any , we can construct a pathlet-preserving simplification in time.
5 The universe and greedy set cover
Subtrajectory clustering is closely related to the set cover problem. In this problem, we have a discrete universe and a family of sets in this universe, and the goal is to pick a minimum number of sets in such that their union is the whole universe. The decision variant of set cover is NP-complete [18]. However, the following greedy strategy gives an approximation of the minimal set cover size [12]. Suppose we have picked a set that does not yet cover all of . The idea is then to add a set that maximizes , and to repeat the procedure until is fully covered.
Defining the universe .
We apply this greedy strategy to subtrajectory clustering, putting the focus on constructing a pathlet that covers the most of some universe . For subtrajectory clustering, the universe is, in principle, infinite. We therefore first define a discrete universe consisting of intervals that together cover . We choose this universe carefully, as an optimal covering of with pathlets must have roughly the same size as an optimal covering of . We define using the following set of critical points in :
Definition 9.
For and , consider their corresponding cell (the area ) and the following six extreme points:
-
A leftmost point of ,
-
A rightmost point of ,
-
The leftmost and rightmost points of , and
-
The leftmost and rightmost points of .
Let be the set of corresponding -coordinates and . For each , we call every point that is an endpoint of a connected component (vertical segment) of a critical point.
Definition 10.
Let be the set of critical points, sorted by their -coordinate. We define the set as the set of intervals in between two consecutive -coordinates in . Since there are at most critical points in for each and , it follows that .
Lemma 11.
We can construct in time.
Proof.
Fix an integer . We compute the critical points inside the cells , for all , in time altogether. For this, we compute the sets of Definition 9 in time each. Let . Then, we compute the intersections of each vertical line , for , in time each. The critical points inside the cells , for , are the endpoints of connected components of these intersections, and can be computed in time per line, totalling time. Summing over all integers completes the proof.
Applying greedy set cover.
In the remainder of this paper, we let denote this discrete universe. For notational convenience, we denote for a pathlet by the set . We generalize the analysis of the greedy set cover argument to pathlets that cover a (constant) fraction of what the optimal pathlet covers. This relaxes the requirements on the pathlets and helps reduce complexity of the problem. For this, we introduce the following:
Definition 12 (Maximal pathlets).
Given a set of pathlets, a -maximal -pathlet is a pathlet such that there exists no -pathlet with
In Lemma 13, we show that if we keep greedily selecting -maximal pathlets for our clustering, the size of the clustering stays relatively small compared to the optimum size. The bound closely resembles the bound obtained by the argument for greedy set cover.
Lemma 13.
Iteratively adding -maximal pathlets yields a clustering of size at most .
Proof.
Let be an -clustering of of minimal size. Then . Consider iteration of the algorithm, where we have some set of -pathlets . Denote by the “size” of the part of the universe that still needs to be covered. Since covers , it must cover . It follows via the pigeonhole principle that there is at least one -pathlet that covers at least intervals in . Per definition of being -maximal, our greedy algorithm finds a pathlet that covers at least uncovered intervals. Thus:
We have that . Suppose it takes iterations to cover all of with the greedy algorithm. Then before the last iteration, at least one edge of remained uncovered. That is, . We apply that for all real to obtain:
for all . Plugging in , it follows that
Hence , showing that . Thus after iterations, all of , and therefore , is covered. Using that completes the proof.
6 Subtrajectory clustering
In this section we present our algorithm for subtrajectory clustering. We first restrict our attention to reference curves of two types.
Recall that using the pathlet-preserving simplification of , we may already restrict our attention to reference curves that are subcurves of . Still, the space of possible reference curves remains infinite. We wish to discretize this space by identifying certain finite classes of reference curves that contain a “good enough” reference curve, i.e., one with which we can construct a pathlet that is -maximal for some small constant .
We distinguish between two types of pathlets, based on their reference curves (note that not all pathlets fit into a class, and that some may fit into both classes):
-
1.
Vertex-to-vertex pathlets: pathlets where is a vertex subcurve of .
-
2.
Subedge pathlets: pathlets where is a subsegment of an edge of .
We construct pathlets of the above types, ensuring that they all cover at least some constant fraction of the optimal coverage for pathlets of the same type. Let and respectively be a vertex-to-vertex and subedge -pathlet, that respectively cover at least a factor and of an optimal pathlet of the same type. We show that one of these two pathlets is a -maximal pathlet, for . For intuition, refer to Figure 4.
Lemma 14.
Given a collection of pathlets, let
be a pathlet with maximal coverage among the uncovered points. Then is -maximal with respect to , for .
Next we combine the previous ideas on simplification and greedy algorithms and present our algorithm for subtrajectory clustering. The algorithm uses subroutines for constructing the two types of pathlets described above, as well as a data structure for comparing their coverages to select the best pathlet for the clustering.
Our pathlet construction algorithms guarantee that and . By Lemma 14, the pathlet with the most coverage is therefore -maximal with respect to the uncovered points, for . By Lemma 13, the resulting -clustering has a size of at most . We show in our constructions of the pathlets that .
A data structure for comparing pathlets.
Recall that we fixed some discrete universe of intervals, and that we denote . In each iteration of our greedy algorithm, we select one of two pathlets whose coverage is the maximum over , given the current set of picked pathlets . To compare the coverages of pathlets, we make use of binary search trees built on and :
Lemma 15.
In time, we can preprocess and into a data structure of size, such that given a pathlet , the value can be computed in time.
Proof.
We make use of a general data structure for storing a set of interior-disjoint intervals, such that given a query interval , the number of intervals in that are fully contained in can be reported efficiently. For the data structure, we store the (multiset of) endpoints of intervals in in a balanced binary search tree. The tree uses space and is constructed in time.
We report the number of intervals in contained in a query interval as follows. An interval is contained in if and only if both and are. Furthermore, there are intervals in that intersects but does not contain. Thus, if contains endpoints stored in the binary search tree, then it contains intervals of . We compute by reporting the intervals of containing the endpoints of in time. Computing and then reporting takes an additional time. Thus we answer a query in time.
We use the above data structure to efficiently compute for a query pathlet . For this, we preprocess both and into the above data structure. Since and , this takes time, and the data structures use space. With the two data structures, we report the values and in time. We then report
Asymptotic complexities.
Our algorithm iteratively constructs a set of pathlets. Before we start constructing pathlets, we compute the universe of intervals. This takes time (Lemma 11).
In each iteration, we construct the data structure of Lemma 15 on the universe and current set of pathlets . This takes time and uses space. Constructing the vertex-to-vertex pathlet then takes time and uses space (Theorem 19). The subedge pathlet takes time and space to construct (Theorem 21).
To decide which pathlet to use in the clustering, we make further use of the data structure of Lemma 15. All constructed pathlets have , and so we compute the coverages of the two pathlets in time. By summing up all complexities, we derive our main theorem:
Theorem 16.
Given a trajectory with vertices, an integer , and a value , we can construct an -clustering of size at most in time and using space.
7 The reachability graph
Let . For any subcurve of and a set of points in we define the reachability graph . The vertices of this graph are the set of points , together with some Steiner points in . The reachability graph is a directed graph where, for any two , there exists a directed path from to if and only if is reachable from in the free space .
A more detailed description of the reachability graph is provided in the full version. There we show that our definition of the graph has vertices and edges, and can be constructed in time.
Theorem 17.
Let be a subcurve of and a set of points in . The reachability graph has vertices and edges, and can be constructed in time.
8 Vertex-to-vertex pathlets
Let , and let be a set of pathlets. Recall that we can compute , for a given pathlet , in time (Lemma 15). We fix some integer . We then give an algorithm for constructing a vertex-to-vertex -pathlet where starts at the ’th vertex of , and its coverage over is maximum.
We find for each subcurve of of length at most a reference-optimal -pathlet. To this end, we consider each vertex of separately. We construct a set of reference-optimal pathlets . We let each interval contain all maximal intervals for which , and thus all maximal intervals for which can reach by a bimonotone path in .
Recall that in Definition 9 we defined a set of critical points. Let denote all critical points in of the form , for integers . That is, contains for all the endpoints of all connected components (vertical line segments) of . Since each cell has at most such critical points, it follows that . Observe that for any -matching between and a vertex-to-vertex subcurve, we can always extend each curve in the matching to start and end at a point in :
Observation 18.
Let be a vertex-to-vertex -pathlet where starts at the ’th vertex. Then there exists an -pathlet with such that for each interval in , the corresponding bimonotone path in starts and ends at a point in .
We create a sweepline algorithm that, for each , constructs a reference-optimal -pathlet . We let each interval contain all maximal intervals for which , and thus all maximal intervals for which can reach by a bimonotone path in . Note that both and are critical points. Thus we aim to find all maximal intervals for which contains a bimonotone path between critical points and .
To this end, we construct, for each , the reachability graph from Section 7, which encodes reachability between all critical points. This graph takes time to construct and has complexity (see Theorem 17). We aim to annotate each vertex (which does not necessarily have to be a critical point) in with the minimum , such that there exists a critical point that can reach . We annotate with if no such value exists.
Annotating vertices.
We begin by annotating the vertices in time, by scanning over them in order of increasing -coordinate. We go over the remaining vertices in -lexicographical order, where we go over the vertices based on increasing -coordinate, and increasing -coordinate when ties arise. Each vertex that we examine has only incoming arcs originating from vertices below and left of . By our lexicographical ordering, each of these vertices are already annotated. The minimal for which there exists a path from to , must be the minimum over all its incoming arcs which we compute in time proportional to the in-degree of . If has no incoming arcs, we annotate it with .
Let and be the sets of vertices and arcs of . For the above annotation procedure, we first compute the -lexicographical ordering of the vertices, based on their corresponding points in the parameter space. This takes time. Afterwards, we go over each vertex and each incoming arc exactly once, which take an additional time. In total, we annotate all vertices in time.
Constructing the pathlets.
With the annotations, constructing the pathlets becomes straightforward. For each , we construct as follows. We iterate over all critical point in the graph . For each critical point with a finite annotation , we add the interval to . This procedure ensures that contains all maximal intervals for which , creating an optimal pathlet with respect to its reference curve. Since there are critical points per , this algorithm uses time. Storing the pathlets takes space. We conclude:
Theorem 19.
Suppose is preprocessed by Lemma 15. In time and using space, we can construct an optimal vertex-to-vertex -pathlet .
Proof.
For a given vertex , we compute optimal pathlets with respect to their reference curves for in time, using space. Using the data structure of Lemma 15, we subsequently compute the coverage of one of these pathlets time, so time for all. We pick the best pathlet and remember its coverage. Doing so for all vertices of , we obtain pathlets, of which we report the best. By only keeping the best pathlet in memory, rather than all , the space used by these pathlets is lowered from to .
9 Subedge pathlets
Let , and let be a set of pathlets. We assume that has at most connected components. We construct a subedge -pathlet whose coverage over is at least ’th of the the optimum.
Recall that a subedge pathlet is a pathlet where is a subsegment of some edge of . We construct a subedge pathlet given the edge . To this end, recall that in Definition 9 we defined a set of critical points. Let denote all critical points in . Since there are at most critical points per cell in the free-space diagram, there are at most critical points in . We fix throughout this section and compute subedge pathlet with at least one-fourth the coverage of any pathlet that uses a subedge of as a reference curve, and where for all , the points and are both critical points.
Before we restrict pathlets to be defined by these critical points, we initially allow a broader range of pathlets. We consider the edge , obtained by reversing the direction of , and look at constructing a pathlet that is a subedge of either or . We show that by restricting pathlets to be defined by , allowing for reference curves that are subcurves of , we lose only a factor four in the maximum (discrete) coverage.
Lemma 20.
Let be a set of pathlets. For any subedge -pathlet , there exists a subedge -pathlet with
where is equal to or for some and , and for every interval , the points and are contained in .
Proof.
Consider a subedge -pathlet . Any interval corresponds to a bimonotone path from to in . Consider such an interval and a corresponding path .
Suppose first that for some . Observe that every connected component of is bounded on the left and right by (possibly empty) vertical line segments, and that the bottom and top chains are parabolic curves whose extrema are the endpoints of these segments. In particular, these connected components are convex. Thus there is a straight line segment from to in the free space. The line segment connecting the extrema of the parabolic curves bounding the connected component containing and is longer than . The endpoints of are both critical points, and describes a valid matching between a subcurve of and either a subcurve of , or a subcurve of . See Figure 5. As there are four different reference curves we choose from, the resulting intervals are spread over four different pathlets. Therefore, one of the pathlets must have at least one-fourth the coverage of any subedge pathlet.
Next suppose that for some . At some point, reaches a point . Let be the lowest point in the connected component containing . This point is a critical point. By convexity, the segment from to lies in the free space. Because by our choice of , we may connect to the suffix of that starts at to obtain a matching that starts at a critical point and that covers at least as much of as the original matching. Applying a symmetric procedure to the end of yields a matching that starts and ends at critical points without losing coverage. Again, since there are four different reference curves to choose from for the intervals in , the resulting intervals are spread over four different pathlets. One of the pathlets must therefore have at least one-fourth the coverage of any subedge pathlet. We find for each point of corresponding to a critical point a subedge pathlet whose reference curve starts at and ends at some point that also corresponds to a critical point. To this end, we consider each point separately. We proceed akin to the construction for vertex-to-vertex pathlets Section 8, with some optimization steps.
It proves too costly to consider each reference curve for every we consider. By sacrificing the quality of the pathlet slightly, settling for a pathlet with at least one-eighth the coverage of any subedge pathlet rather than one-fourth, we can reduce the number of reference curves we have to consider from to . Let be a subedge pathlet. We can split into two subedges and . The matchings corresponding to decompose into two sets of matchings (whose matched subcurves may overlap), giving rise to two pathlets and with . Thus at least one of these pathlets has at least half the coverage that has. By Lemma 20, a pathlet that has maximum coverage out of all such pathlets then covers at least one-eighth of what any other subedge pathlet covers.
Using a sweepline algorithm analogous to that of Section 8, we construct reference-optimal -pathlets using each and with as reference curves. This leads to the following result (for details, see the full version):
Theorem 21.
Suppose that the universe and the coverage is preprocessed into the data structure of Lemma 15. In time and using space, we can construct a -pathlet with
for any subedge -pathlet .
10 Conclusion
In this work, we presented an improved approximation algorithm for subtrajectory clustering. We discuss our technical contribution, and how it differs from previous works, our asymptotic improvements and finally interesting directions for future work.
Technical contribution.
Our technical contributions are threefold:
First, we introduced a new type of curve simplification in Section 4. This simplification allows us to construct a curve , such that our clustering needs to consider only pathlets whose reference curve is a subcurve of . Although numerous similar curve-simplification algorithms exist, our method distinguishes itself by lying significantly closer to the input curve . Consequently, our approximation algorithm is a -approximation in , compared to the -approximations of prior works. We consider this simplification to be of independent interest, as future works may immediately use our simplification method to obtain -approximations in also.
Secondly, we considered in Section 6 an extension to the greedy set cover algorithm wherein each iteration adds an approximately-maximum covering element, rather than a maximum one. Observe that can always be divided into at most three subcurves, where at most one of them starts and ends at a vertex of (a vertex-subcurve) and at most two of them are subcurves of an edge of (a subedge of ). We design a greedy meta-algorithm, that in each iteration computes an -pathlet with approximately-maximum coverage, whose reference curve is a vertex-subcurve or subedge of . Our approximately greedy set cover analysis shows that our meta-algorithm computes a clustering of size . A key takeaway from our construction is that by restricting our attention to vertex-subcurves and subedges of , we significantly reduce the set of candidate pathlets from to . We consider this fact to also be of independent interest. Indeed, our subsequent algorithm spends near-linear time per candidate pathlet but future works may discover more efficient algorithms over the same smaller candidate set.
Finally, we presented algorithms in Sections 8 and 9 that compute the corresponding candidate pathlet for a candidate reference curve in near-linear time and near-linear space. The key observation to this contribution is that we show that it suffices to compute all candidate pathlets on the fly, significantly reducing the space.
Asymptotic improvements.
Compared to the best prior deterministic work [13], our algorithm improves the running time by a factor near-linear in , improves the space by a factor near-linear in , and improves the approximation in from a factor to , all whilst asymptotically matching the size of the clustering. We consider this a significant improvement over the state-of-the-art.
When we compare to previous randomized work [5, 3] we improve the running time by a factor near-linear in , improve space by a factor , and improve the approximation in from a factor to . A downside of our approach is that, compared to randomised works, we only asymptotically match the clustering size whenever is relatively large (i.e., ). However, we note that on all other algorithmic quality measures, we still offer a substantial improvement whilst also being deterministic. In addition, when considering algorithmic performance in practice, we note that these previous randomized results [5, 3] use -net sampling. Such a sampling procedures leads to very high hidden constants in the asymptotic clustering size which makes such an approach impractical.
Future work.
We think it remains an interesting open problem whether one can obtain a clustering size of in a deterministic manner. We also note that, currently, our algorithm considers a set of reference curves , and computes an -pathlet with approximately-maximum coverage for each reference curve independently, in near-linear time. We think it is an interesting open problem whether one can present an algorithm that is overall more efficient whenever these maximum pathlets are considered simultaneously rather than independently.
References
- [1] Pankaj K. Agarwal, Kyle Fox, Kamesh Munagala, Abhinandan Nath, Jiangwei Pan, and Erin Taylor. Subtrajectory clustering: Models and algorithms. In proc. 37th ACM SIGMOD-SIGACT-SIGAI Symposium on Principles of Database Systems (PODS), pages 75–87, 2018. doi:10.1145/3196959.3196972.
- [2] Pankaj K. Agarwal, Sariel Har-Peled, Nabil H. Mustafa, and Yusu Wang. Near-linear time approximation algorithms for curve simplification. Algorithmica, 42(3):203–219, 2005. doi:10.1007/s00453-005-1165-y.
- [3] Hugo A. Akitaya, Frederik Brüning, Erin Chambers, and Anne Driemel. Subtrajectory clustering: Finding set covers for set systems of subcurves. Computing in Geometry and Topology, 2(1):1:1–1:48, 2023. doi:10.57717/cgt.v2i1.7.
- [4] Helmut Alt and Michael Godau. Computing the Fréchet distance between two polygonal curves. International Journal of Computational Geometry & Applications, 5:75–91, 1995. doi:10.1142/S0218195995000064.
- [5] Frederik Brüning, Jacobus Conradi, and Anne Driemel. Faster approximate covering of subcurves under the Fréchet distance. In proc. 30th Annual European Symposium on Algorithms (ESA), pages 28:1–28:16, Dagstuhl, Germany, 2022. doi:10.4230/LIPIcs.ESA.2022.28.
- [6] Kevin Buchin, Maike Buchin, David Duran, Brittany Terese Fasy, Roel Jacobs, Vera Sacristan, Rodrigo I. Silveira, Frank Staals, and Carola Wenk. Clustering trajectories for map construction. In proc. 25th ACM SIGSPATIAL International Conference on Advances in Geographic Information Systems, pages 1–10, 2017. doi:10.1145/3139958.3139964.
- [7] Kevin Buchin, Maike Buchin, Joachim Gudmundsson, Jorren Hendriks, Erfan Hosseini Sereshgi, Vera Sacristán, Rodrigo I. Silveira, Jorrick Sleijster, Frank Staals, and Carola Wenk. Improved map construction using subtrajectory clustering. In proc. 4th ACM SIGSPATIAL Workshop on Location-Based Recommendations, Geosocial Networks, and Geoadvertising, pages 1–4, 2020. doi:10.1145/3423334.3431451.
- [8] Kevin Buchin, Maike Buchin, Joachim Gudmundsson, Maarten Löffler, and Jun Luo. Detecting commuting patterns by clustering subtrajectories. International Journal of Computational Geometry & Applications, 21(03):253–282, 2011. doi:10.1142/S0218195911003652.
- [9] Kevin Buchin, Anne Driemel, Joachim Gudmundsson, Michael Horton, Irina Kostitsyna, Maarten Löffler, and Martijn Struijs. Approximating -center clustering for curves. In proc. Thirtieth Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 2922–2938, 2019. doi:10.1137/1.9781611975482.181.
- [10] Maike Buchin and Dennis Rohde. Coresets for -median clustering under the Fréchet distance. In proc. 8th International Conference on Algorithms and Discrete Applied Mathematics (CALDAM), pages 167–180, 2022. doi:10.1007/978-3-030-95018-7_14.
- [11] Siu-Wing Cheng and Haoqiang Huang. Curve simplification and clustering under Fréchet distance. In proc. 2023 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 1414–1432, 2023. doi:10.1137/1.9781611977554.ch51.
- [12] Vasek Chvátal. A greedy heuristic for the set-covering problem. Mathematics of Operations Research, 4(3):233–235, 1979. doi:10.1287/MOOR.4.3.233.
- [13] Jacobus Conradi and Anne Driemel. Finding complex patterns in trajectory data via geometric set cover. arXiv preprint arXiv:2308.14865, 2023. doi:10.48550/arXiv.2308.14865.
- [14] Mark de Berg, Atlas F. Cook, and Joachim Gudmundsson. Fast Fréchet queries. Computational Geometry, 46(6):747–755, 2013. doi:10.1016/j.comgeo.2012.11.006.
- [15] Anne Driemel, Amer Krivošija, and Christian Sohler. Clustering time series under the Fréchet distance. In proc. twenty-seventh annual ACM-SIAM symposium on Discrete algorithms (SODA), pages 766–785, 2016. doi:10.1137/1.9781611974331.ch5.
- [16] Joachim Gudmundsson and Sampson Wong. Cubic upper and lower bounds for subtrajectory clustering under the continuous Fréchet distance. In proc. 2022 Annual ACM-SIAM Symposium on Discrete Algorithms (SODA), pages 173–189, 2022. doi:10.1137/1.9781611977073.9.
- [17] Leonidas J. Guibas, John Hershberger, Joseph S. B. Mitchell, and Jack Snoeyink. Approximating polygons and subdivisions with minimum link paths. International Journal of Computational Geometry & Applications, 3(4):383–415, 1993. doi:10.1142/S0218195993000257.
- [18] Richard M. Karp. Reducibility among combinatorial problems. In proc. Symposium on the Complexity of Computer Computations, The IBM Research Symposia Series, pages 85–103, 1972. doi:10.1007/978-1-4684-2001-2_9.
- [19] Mees van de Kerkhof, Irina Kostitsyna, Maarten Löffler, Majid Mirzanezhad, and Carola Wenk. Global curve simplification. European Symposium on Algorithms (ESA), 2019.
- [20] Peter Widmayer. On graphs preserving rectilinear shortest paths in the presence of obstacles. Annals of Operations Research, 33(7):557–575, 1991. doi:10.1007/BF02067242.