Minimizing Walking Length in Map Matching

. In this paper, we propose a geometric algorithm for a map matching problem. More speciﬁcally, we are given a planar graph, H , with a straight-line embedding in a plane, a directed polygonal curve, T , and a distance value ε > 0. The task is to ﬁnd a path, P , in H , and a parameterization of T , that minimize the sum of the length of walks on T and P whereby the distance between the entities moving along P and T is at most ε , at any time during the walks. It is allowed to walk forwards and backwards on T and edges of H . We pro-pose an algorithm with O ( mn ( m + n ) log( mn )) time complexity and O ( mn ( m + n )) space complexity, where m ( n , respectively) is the number of edges of H (of T , respectively). As we show, the algorithm can be generalized to work also for weighted non-planar graphs within the same time and space complexities.


Introduction
Trajectory data are often obtained from global positioning system (GPS) devices.Such devices have accuracy limitations due to noise, sampling intervals, or poor signals (e.g., inside buildings) thus raw spatial trajectories tend not to be accurate.Under the assumption that the travel captured by the trajectory was following edges of a map (stored as a graph) the map matching problem arises.It asks to find a path on the map that "corresponds well" to the given trajectory.Map matching arises in different contexts and is a necessary step in preprocessing raw data before data mining [1].A variety of approaches have been used to solve the map matching problem (e.g.geometric, probabilistic methods, fuzzy logic, neural networks).In [2], Chen et al. discussed recent map matching algorithms when a trajectory is obtained from low-frequency GPS data of vehicles driving on a road network.Ruan et al. [3] studied indoor map matching technology based on personal motion states.In [4], Asakura et al. proposed a pedestrian-oriented map matching algorithm in the context of disasters.In this context, refugees have battery-driven mobile GPS terminals and move to shelters at walking speed.They stated that in order to reduce battery consumption (which is vital in this context), they chose a geometric approach in which computation resources are less utilized when compared e.g., with probabilistic methods.
In this paper, we focus on geometric approaches.We assume that a map is given as a planar graph via a straight-line embedding in a plane.Therefore, a path in the graph corresponds to a polygonal curve in the plane.A trajectory is given as a directed polygonal curve from a starting point to an ending point.The objective is to find a path in the map which is most similar to the given trajectory.
To measure similarity, [1] and [7] observe that methods which consider global features of the input trajectories achieve more accurate results than local approaches.The Fréchet distance is a global similarity measure between curves, see e.g., the seminal paper [6].Commonly, the Fréchet distance is illustrated as follows: Suppose a person wants to walk along one curve and his/her dog on another; the person is keeping the dog at a leash.Both person and dog walk, from starting point to ending points along their respective curves.The standard Fréchet distance is the minimum leash length required without either person or dog needing to backtrack.The weak Fréchet distance is a variant of the standard Fréchet distance in which backtracking on one or both curves is allowed.Alt and Godau [6] proposed algorithms to compute the standard and weak Fréchet distances in O(n 2 log n) time, where n is the maximum number of segments in the input polygonal curves.Har-Peled and Raichel [15] showed that the weak Fréchet distance can be computed in quadratic time.
In [5], Alt et al. discussed the map matching problem set in the context of the standard Fréchet distance.I.e., their algorithm finds a path in the planar graph with minimum Fréchet distance to the given trajectory.The time complexity of their algorithm is O(mn log 2 mn) where m (n, respectively) is the number of edges in the input planar graph (the input polygonal curve, respectively).Brakatsoulas et al. [7], extended the map matching algorithm of [5] for the weak Fréchet distance.The time complexity of their algorithm is O(mn log mn).In [8], Chen et al. proposed a (1 + ε)-approximation algorithm for the map matching problem when the similarity measure is the standard Fréchet distance and input model is more "realistic".They assumed that the input polygonal curve is cpacked and the input graph is φ-low density in R d (see Section 2 of [8]).
In [10], Gheibi et al. studied a natural optimization problem on the weak Fréchet distance, called the minimum backward Fréchet distance (MBFD) problem.There, the task is to determine a pair of walks for a given input leash length such that the total length of backtracking on both input polygonal curves is minimized.The cost of backtracking could represent, for example, the cost of moving against a flow, or the cost for a moving entity (e.g., a human, a humanoid robot) to move backwards because of the entity's physiology [9].They proposed an algorithm solving this problem within time complexity O(n 2 log n) and space complexity O(n 2 ), where n is the maximum number of segments in the polygonal curves.In [11], the weighted variant of the MBFD problem is solved in O(n 3 ) time.In this variant, each edge of the input polygonal curves has an associated non-negative weight to capture different costs for backward movement.
In this paper, we study the map matching problem when the similarity measure is the MBFD.More specifically, as input, we are given: a planar graph, H, with a straight-line embedding in a plane, a directed polygonal curve, T , and a distance ε > 0. As motions, both forward and backward motions along T and the edges of H are allowed.The objective is to find a path, P , in H, and a parameterization of T , that minimize the sum of the walk lengths along T and P while keeping a leash length of at most ε.We restrict the start and end point of P to be at a vertex of H.However, P may partially contain an edge of H.The difference between this problem setting and that optimization setting of [5] and [7], is that here the total walking length along T and P is minimized while in the other settings the leash length is minimized.The optimization problem introduced in this paper, can also be used to track objects moving on road networks.To ensure high-quality tracking, the mobile tracker must remain within a distance of ε to the moving object, at all time.To minimize energy consumption, the tracker wants to minimizes walking distance.This type of scenario has been discussed in the context of wireless networks (see [12] and [13]).Figure 1 shows an example of an embedding of a planar graph, H, in R 2 , a polygonal curve, T , and a length ε.The dog walks on T from T (0) to T (4) and the person chooses a path in H, from one vertex of H to another vertex.Two points, a and b, are determined on v 4 , v 5 and v 3 , v 4 respectively.A path in H, and a walk on T , that minimize the walking lengths on H and T , are as follows: the dog starts at T (0) and continues on T .The person starts at v 1 and walks on the edges v 1 , v 3 , v 3 , v 4 , and v 4 , v 5 .They move together in a forward direction until the dog reaches the end of the second segment of T and the person reaches the point a on v 4 , v 5 .Then, the dog continues to move forwards until the end of the third segment of T is reached, while the person moves backwards from a to v 4 and then to b.At the final step, they move forwards again together until the dog reaches the end of T and the person reaches v 5 .We show the path in the graph by the sequence of its vertices, The structure of this paper is as follows.In Section 2, we discuss preliminaries and define the problem formally.In Section 3, we propose a polynomial time algorithm for the map matching problem introduced.Then, in Section 4, we develop an algorithm with improved time and space complexities.In Section 5, we sketch a solution to a weighted problem variant.Finally, in Section 6, we conclude the paper.

Preliminaries and Definitions
A geometric path in R 2 is a sequence of points in 2D Euclidean space, R 2 .A polygonal curve, or a discrete geometric path, is a geometric path, sampled by a finite sequence of points (called vertices), which are connected by line segments (called edges) in order.Let T : [0, n] → R 2 be a polygonal curve with n segments.A vertex of T is denoted by T (i), i = 0, . . ., n.Let H = V H , E H be a planar graph with a straight-line embedding in R 2 where V H (E H , respectively) is the set of vertices (edges, respectively) of H.In this paper, the geometric embedding of H is crucial and we simply refer to the straight-line embedding of the graph in R 2 as H.A path, P , in H, is a polygonal curve P : [0, 1] → H, such that P ⊂ H and P (0), P (1) ∈ V H .
A parameterization of a polygonal curve, T : [0, n] → R 2 , is a continuous function f : [0, 1] → [0, n], where f (0) = 0 and f (1) = n.Note that a parameterization is corresponding to a walk on T and the interval [0, 1] is representing time during the walk.Walking Length.Let f be a parameterization of a polygonal curve, T .Let D f ⊆ [0, 1] be the closure of the set of times in which f (t) is decreasing (i.e., the movement is backward).The walking length of T is defined by Formula 1, where . is the Euclidean norm and (.) is derivative.
Note that if f is monotone (i.e., there is no backward movements on T ), then Problem Definition.Suppose H, T and a length, ε > 0, are given.The objective is to find a path in H and a parameterization of T such that sum of the length of P and the walking length of T is minimized (Formula 2).We consider only paths in the graph and parameterizations of T that guarantee to maintain the leash length at most ε, during the walks.
Deformed free-space surface.The free-space diagram is a structure, used to decide whether the Fréchet distance between two polygonal curves is upper bounded by a given ε [6].In [5], Alt et al. introduced a 3D structure, called free-space surface, to solve the decision version of their map matching problem.
Here, we use both free-space diagram and free-space surface.However, we modify them slightly, to fit our problem setting.
, partitioned into n columns and k rows.It consists of nk parameter cells C x,y , for x = 1, ..., n and y = 1, ..., k.Cell C x,y is the result of the product of two sub-intervals of [0, 1] that are mapped to edge where d is the Euclidean distance; otherwise, we call it black.It has been shown that the set of all white points inside a cell C x,y is determined by the intersection of an ellipse with C x,y .This set is called the free-space region of that cell.The boundaries of a cell and its corresponding ellipse intersect at most eight times.These intersection points form at most four intervals of white points on the boundary of the cell (i.e., at most one interval per side of the cell).Note that two adjacent cells have the same interval on the shared side between the cells.The union of all cells' freespaces is the free-space (or white-space) of the diagram; it is denoted by W P .The complement of W P is the forbidden-space (or black-space) of the diagram and is denoted by B P .We stretch/compress the columns and rows of the freespace diagram, such that their widths and heights are equal to the lengths of the corresponding segments of T and P , respectively.The resulting diagram is called the deformed free-space diagram and is denoted by F ε (T, P ).In Figure 2, the free-space diagram F ε (T, P * ) is drawn, where is a path in H, denoted as a sequence of its vertices.
Note that if the path P contains only a single vertex of H, v i ∈ V H , then F ε (T, P ) is a line segment and its length is equal to the Euclidean length of T .We call this 1D free-space diagram, F i , the deformed free-space line of v i .We denote the left endpoint of F i (i.e., the endpoint corresponding to T (0)) by s i and the right endpoint of F i (i.e., the endpoint corresponding to T (n)) by t i .If P contains only an edge, v i , v j ∈ E H , of H, then F ε (T, P ) has only one row.We call this row the deformed free-space face of v i , v j , and denote it by F j i .Note that F j i and F k j have F j in common.Therefore, gluing F j i and F k j along F j produces a conforming surface.Thus, we can construct the deformed freespace surface as follows.We first lay out the straight-line embedding of H in the xy-plane.For each edge v i , v j ∈ E H , we lay out F j i , orthogonal to the xy-plane, along z axis, such that F i (F j , respectively) is on top of v i (v j , respectively) and s i (s j , respectively) is in the xy-plane.Note that F j i is stretched along z axis from the plane z = 0 to the plane Fig. 2. The free-space diagram Fε(T, P * ) is drawn.WP is the white area and BP is the gray area.
v k ∈ Adj(v j ).Also, we glue The result is a conforming 3D surface between two planes, z = 0 and z = T , called deformed free-space surface and is denoted by S = H × [0, T ].Note that s i is on the plane z = 0 and t i is on the plane z = T , i = 1, . . ., |V H |. The union of the white-space (black-space, respectively) of all faces of S is called the whitesurface (black-surface, respectively) and is denoted by W (B, respectively).For the given planar graph H, the polygonal curve T , and the length ε in Figure 1, the corresponding deformed free-space surface is shown in Figure 3, from two points of views.Since the white-space of each cell of any F j i is convex, for simplicity, we just draw the white-space intervals on the boundary of the cells.In this figure, the red dashed polygonal curve is a path on the white-surface W, from s 1 to t 5 , that realizes , in H, and a parameterization of T , that is an optimal solution to our problem setting.It intersects the following free-space faces sequentially:

Algorithm
In this section, we first transform the map matching problem to a shortest path problem on a weighted graph, G = V, E ; this yields a polynomial time algorithm.Before discussing the construction of G, we introduce a set of Steiner points on the boundary of the cells of S. Steiner Points.We position Steiner points so as to create intervals on the boundary of the cells of S.There are two types of intervals, Type 1 and Type 2. We classify the Steiner points based on the type of the intervals that they belong to.We denote the set of Type 1 (Type 2, respectively) Steiner points by S 1 (S 2 , respectively).The red dashed polygonal curve is a path on the white-surface that realizes an optimal solution to our problem setting.
Type 1.We say an interval is Type 1, if it lies completely in a plane, z = c, parallel to the xy-plane, where c is a constant.Each deformed free-space face, F j i , may have n + 1 Type 1 intervals, FI j i ( ), = 0, . . ., n, shared between its cells (where n is the number of edges in T ).For each interval FI j i ( ), we project the endpoints of FI j i ( ) orthogonally to all FI j i (k), k = .If the line segment from an endpoint of FI j i ( ) to its projection on FI j i (k) lies in the free-space of F j i and the projection point is not identical with an endpoint of FI j i (k), then we take the projection point as a Type 1 Steiner point (see Figure 4).The set of all Steiner points, obtained by the projections on F j i , for all v i , v j ∈ E H , is denoted by S 1 .
Type 2. We say an interval is Type 2 if it lies completely on a deformed freespace line.As we mentioned in Section 2, a plane z = c corresponds to a point on the given trajectory T .The intersection of z = c and S is an instance of H, denoted by H c .Note that some part (possibly empty) of H c is in W. Let z = h j be the corresponding plane of T (j), a vertex of T .The part of the deformed .In T j j−1 , j = 1, . . ., n, there is at most one Type 2 interval per vertex v i ∈ V H .We denote these Type 2 intervals by T I j j−1 (i), i = 1, . . ., |V H |. Suppose z = c is the plane that is passing through an endpoint, p, of T I j j−1 (i).Let the intersection of z = c with T I j j−1 (k), k = i, be q k .Note that both p and q k are on the graph H c .Then, if q k is not an endpoint of T I j j−1 (k) and there is a path, from p to q k , in H c , that is in W, then q k is a Type 2 Steiner Point.The set of all Type 2 Steiner points is denoted by S 2 .An example is given in Figure 5. Suppose it is T j j−1 , for j = 1.In this example, there are four yellow intervals, T I j j−1 (1), T I j j−1 (3), T I j j−1 (5), and T I j j−1 (6).The black points show the interval endpoints and red points show the Type 2 Steiner points.For simplicity, only two, out of eight planes, are drawn.The plane z 3 (z 6 , respectively) is passing through an endpoint of T I j j−1 (3) (T I j j−1 (6), respectively).The intersections of z 3 with T I j j−1 (5) and T I j j−1 (6) are Steiner points.However, the intersection of z 6 with T I j j−1 (3) is not a Steiner point.Constructing Graph.Now, we explain the construction of G = V, E .Recall that the white-surface (the white-space of S) is denoted by W. The vertices of W are the end points of the intervals on the boundary of the cells in S (at most 4 intervals may exist per cell).We denote the set of vertices of W by V W .The set of vertices, V , of G, is V = V W ∪ S 1 ∪ S 2 .Note that V contains all s i and t i if they are in W. Every two vertices, v 1 , v 2 ∈ V , that are on the boundary of a cell, are linked by two directed edges in E, from v 1 to v 2 , v 1 , v 2 , and vice versa, v 2 , v 1 .The weight of an edge e = v 1 , v 2 ∈ E, is its length in the L 1 metric, |e| 1 .Obtain an Optimal Solution.In order to have an optimal solution, at least one s i and one t j , i, j = 1, . . ., |V H |, must be in W. The main steps of the algorithm are as follows: -Find all the vertices in V H that are in ε distance of T (0) (T (n), respectively), v i1 , . . ., v i k 1 (v j1 , . . ., v j k 2 , respectively).-Add an extra node, s , to G, and add k 1 extra directed edges, s , s i1 , . . ., s , s i k 1 , to E. The weight of these k 1 edges are set to zero.Analogously, add another extra node, t , to G, and add k 2 extra directed edges, t j1 , t , . . ., t j k 2 , t , to E. The weight of these k 2 edges are also set to zero.-Find a shortest path, from s to t , in G.Note that if there is no path from s to t in G, then there is no solution for the given leash length.-Remove s and t from the head and tail of the shortest path.The remaining path is from one s i to one t j .It gives an optimal solution to our problem setting.
Note that, a vertex of G (except s and t ) is also represented by a point in W. Therefore, the geometric embedding of a path, from one s i to one t j , in G, is constructed by connecting the consecutive vertices of the path in W by line segments.
Observation 1 Let Π be a path in the white-space, W, of a deformed free-space surface, S, from one s i to one t j .Π realizes a path, P : [0, 1] → H, in H, and a parameterization, f : [0, 1] → [0, n], of T , that maintain the leash length at most ε, for all t ∈ [0, 1].
Constructing a path in H.We can construct a path P in H, from the given path Π in W, as follows.As we mentioned earlier in this section, we have two types of intervals on the boundary of the cells, Type 1 and Type 2. A Type 1 interval lies completely on a plane, z = c, parallel to the xy-plane.A Type 2 interval lies completely on a deformed free-space line, F i .The path Π intersects a sequence of intervals (of both types).The path P in H is constructed by processing the intervals in this sequence.For each interval in this sequence, if it is Type 2 interval, on F i , then we append v i to the tail of P .If it is Type 1, then the intersection point, q, of Π and that interval, is appended to the tail of P , as a vertex of P .Note that q may not be a vertex of H.However, it is a point on an edge of H.At the end, we connect the consecutive vertices in P by straight line segments.Correctness.To establish the correctness, we use norms in two spaces: (1) the Euclidean space of the embedding of the input graph and the polygonal curve, called the input space, (2) the deformed free-space surface, called the configuration space.In the input space, we denote the Euclidean length of a polygonal curve T by T .We also defined walking length of T , L f (T ), based on a parameterization f .Note that if f is a monotone parameterization, then L f (T ) = T .In configuration space, a path from an s i to a t j in W, is also denoted by its vertices, Π : The length of a path, |Π| 1 , is the sum of the length of its segments.Lemma 1 is at the heart of the correctness proof.This section is concluded by a corollary to Lemma 1 and Observation 1, that is, in order to find a solution for our problem setting, it suffices to find a shortest path from s to t in G.
Lemma 1 For any path Π : s i = p 1 , p 2 , . . ., p k1 = t j in W, there is a path Π : Proof.The path Π intersects a sequence, SF , of deformed free-space faces.Every two consecutive faces in SF share a deformed free-space line.Therefore, we can unfold the free-space faces in the sequence, along the shared free-space lines.The result is a 2D free-space diagram, denoted by F ε (SF ).W.l.o.g., we can assume that F ε (SF ) is axis aligned in R 2 .The path Π is also unfolded into a 2D path in the white-space, W SF , of F ε (SF ).Note that unfolding does not change the length of a path.As an example, in Figure 6a, the result of unfolding the faces that are intersected by the red dashed polygonal curve in Figure 3, is shown.
Let Π opt : s i = q 1 , q 2 , . . ., q k3 = t j be a L 1 shortest path, from s i to t j , in W SF .Then, |Π opt | 1 ≤ |Π| 1 .To prove the lemma, it suffices to show that there is a path We know that the vertices of Π opt are endpoints of some intervals on the boundary of the cells of F ε (SF ) [14] (the well known rubber band property of shortest paths).Therefore, the vertices of Π opt are in V (i.e., the set of vertices of G).Thus, it is sufficient to show that for each edge, −−−→ q i q i+1 , of Π opt , there is a path, π qiqi+1 , from Two cases arise depending on whether −−−→ q i q i+1 lies completely within a row (or a column) of F ε (SF ), or not.We need a definition before discussing these cases.We assume that F ε (SF ) is an axis-aligned rectangle in a 2D Cartesian coordinate system, where the x-axis corresponds to T (Figure 6a).We say a path Π ∈ W SF is x-monotone (y-monotone, respectively), if any vertical (horizontal, respectively) line intersects it at most ones.Π is said to be xy-monotone, if it is both x-and y-monotone.Case 1.In this case, −−−→ q i q i+1 lies completely within a column (or a row) of F ε (SF ).Here, we discuss the case when it lies within a column (see Figure 6b); the arguments are analogous for case of a row.W.l.o.g we assume that −−−→ q i q i+1 is xy-increasing.The other cases are symmetric.Edge −−−→ q i q i+1 intersects a sequence of horizontal intervals, I z , within a column.They are sorted based on their y coordinates.We construct π qiqi+1 sequentially and always denote the last vertex appended to π qiqi+1 by π last .Initially, π qiqi+1 contains only q i and π last = q i .The sequence of intervals are processed sequentially.Suppose we processed interval I z and now we want to process I z+1 .We project orthogonally from π last to I z+1 .If the projection point exists (i.e., the perpendicular line from π last to I z+1 intersects I z+1 ), then append the projection point on I z+1 to π qiqi+1 and update π last .Otherwise, the closest endpoint of I z+1 to π last is appended to π qiqi+1 and we update π last .When all intervals, I z , have been processed, q i+1 is appended to π qiqi+1 .
Since the sorted list of intervals withing a column are traversed by π qiqi+1 sequentially, the path π qiqi+1 is y-monotone.Also, by construction, each vertex of π qiqi+1 either has the same x as its preceding vertex in π qiqi+1 (i.e., it is the result of the orthogonal projection) or its x is greater than its preceding vertex's x (since the orthogonal projection does not exist and −−−→ q i q i+1 is xy-increasing inside the white-space).Therefore, the path π qiqi+1 is x-monotone.Thus, the path π qiqi+1 is xy-monotone.We know that the L 1 length of two xy-monotone paths that have the same starting and ending points, are equal.Therefore, Now, we prove that π qiqi+1 ⊂ G = V, E .It suffices to show that each vertex of π qiqi+1 is in V and between every two consecutive vertices of π qiqi+1 there is an edge in E. Each vertex of π qiqi+1 is either the result of the orthogonal projection or an endpoint of an interval.Therefore, each vertex is either a Steiner point or a vertex of the white-surface.In both cases, the vertex is in V .In addition, between every two consecutive vertices of π qiqi+1 there is an edge in E because every two consecutive vertices of π qiqi+1 lie on the boundary of a cell and, by the construction of G, all members of V that lie on the boundary of a cell are linked by edges in E.
Case 2. In [11], Section 4, Lemma 4, it is proved that if −−−→ q i q i+1 does not lie completely within a row and within a column of F ε (SF ), then there is a xymonotone path π qiqi+1 , from q i to q i+1 , such that its edges lie completely within a row and within a column of F ε (SF ).For each edge of π qiqi+1 , we apply case 1.Then, we concatenate the resulting xy-monotone paths for edges of π qiqi+1 , to obtain π qiqi+1 .Since, xy-monotone paths for edges of π qiqi+1 are in G (as we proved in Case 1), the resulting path, π qiqi+1 , is a xy-monotone path in G. Therefore, Corollary 1 For any pair of s i and t j , if t j is reachable from s i by a path in W, then there is a path from s i to t j , in G, that is a L 1 shortest path in W.
Corollary 2 A shortest path in G, from s to t , yields an optimal solution for our problem setting.
Proof.Let Π opt be a shortest path in G, from s to t .We remove s and t from the head and tail of Π opt .The result, Π ij , is a shortest path from s i to t j .Therefore, among all possible shortest paths Π k , for s k and t , k, = 1, . . ., |V H |, the pair (s i , t j ) has a shortest L 1 shortest path, Π ij .By Corollary 1, Π ij ⊂ G is a L 1 shortest path in W. Each point on Π ij is corresponding to a point, p, on H and a point, q, on T , such that the Euclidean distance of p and q is less than ε.By Observation 1, Π ij , is corresponding to a path, P , in H, from v i ∈ V H to v j ∈ V H , and a parameterization, f , of T .The summation of the Euclidean length of P , P , and the walking length of T , L f (T ), is equal to the L 1 length of Π ij .Since Π ij is a shortest L 1 shortest path, P and f minimize the matching cost, M ε (H, T ) (Equation 2).
Theorem 1 Let H be a planar graph with a straight-line embedding in a plane, T be a directed polygonal curve, and ε > 0 be a distance.A path, P : [0, 1] → H, between two vertices of H, and a parameterization, f , of T , that minimize the sum of the walking length of T and P , can be found in polynomial time and space.It is guaranteed that at any time t ∈ [0, 1], the Euclidean distance between P (t) and T (f (t)) is at most ε.
Proof.The correctness follows directly from Corollary 2. The deformed freespace surface, S, has O(mn) cells, where m (n, respectively) is the number of edges of H (T , respectively).Each cell of S has at most four intervals and at most O(m + n) Steiner points on its intervals.Therefore, the graph G has O (mn(m + n)) vertices and O mn(m + n) 2 edges (including the extra edges that connect s and t to the graph).In addition, it takes O n 2 time to compute all Type 1 Steiner points for each free-space face.Therefore, computing S 1 takes O mn 2 time.In order to compute Type 2 Steiner points, we use breadth first search for each interval endpoint to propagate the projection on the instance of the graph, H c , in the plane z = c.Therefore, computing S 2 takes O nm 2 time.At the end, it is possible to find a shortest path in G, from s to t , in O mn(m + n) 2 time, by using Dijkstra's algorithm.Therefore, both the total time and space complexities are O mn(m + n) 2 .

Improvement
In Section 3, we showed that the graph G = V, E contains a path that yields an optimal solution for our problem setting.The bottleneck in the time complexity of the algorithm in Section 3 is due to the number of edges of G.In this section, we construct a new graph G = V, E , such that |E | < |E| and it preserves the connectivity information of G.More precisely, if there is a path, from v i ∈ V to v j ∈ V , in G, then there is a path, from v i to v j , in G , with the same L 1 length.
Based on the construction of G, there are at most O(m + n) vertices in V (including the interval endpoints and Steiner points) on the boundary of each cell, C, of S. We connect these O(m + n) vertices by a linear number of edges, in E , as follows.The weight of each edge in E is equal to its L 1 -length.Let T , B, L, and R be the intervals on the top, bottom, left and right side of C, respectively.Suppose cell C is in a 2D Cartesian coordinate system and the vertices on each interval I ∈ {T, B, L, R} are sorted by x and y.Every two adjacent vertices, v i and v i+1 , on I, are linked by two directed edges, v i , v i+1 and v i+1 , v i (Figure 7).Every two of the eight interval endpoints are linked by two directed edges assuming they are not identical.A vertex v i on interval L (T , respectively), is linked by two directed edges to another vertex v i on R (B, respectively) if v i has the same y (x, respectively) coordinate as v i ; the two edges are denoted by v i , v i and v i , v i , respectively.By this approach, each vertex of G on the boundary of C is connected to a constant number of vertices of G on the boundary of C. It is now straightforward to prove the following lemma.
Lemma 2 Let v i and v j be two vertices, in V , on the boundary of a cell, C, of S.There is a path, from v i to v j , in G , that has the same L 1 length as the direct line segment between them.
Corollary 3 There is a path in G that realizes an optimal solution for our problem setting.T B L R Fig. 7.A cell of the free-space surface is drawn.The red solid line segments show the four intervals on the boundary of the cell.The arcs show the edges in E that connect every two adjacent vertices of G , on each interval.The dashed black line segments show the edges in E that connect a vertex with its orthogonal projection on the opposite side of the cell.The dash dotted blue line segments show some of the edges that connect endpoints of the intervals.For simplicity, we did not draw all of them.
Theorem 2 Let H be a planar graph with a straight-line embedding in a plane, T be a directed polygonal curve, and ε > 0 be a distance.A path, P : [0, 1] → H, between two vertices of H, and a parameterization, f , of T , that minimize the sum of the walking length of T and P , can be found in O(nm(n + m) log(nm)) time and O(nm(n + m)) space, where n (m, respectively) is the number of edges of T (H, respectively).It is guaranteed that at any time t ∈ [0, 1], the Euclidean distance between P (t) and T (f (t)) is at most ε.
Proof.The correctness follows directly from Corollary 3. The number of vertices and edges of G (and the total space complexity) is upper-bounded by O(nm(n+ m)).Using Dijkstra's algorithm, we find a shortest path in G , from s to t .Therefore, the time complexity of our algorithm is O(nm(n + m) log(nm)).Note that if there is no pair of (s k , t ), k, = 1, . . ., |V H |, in a connected component of G , then there is no feasible solution.

Weighted non-planar graphs
We assumed that the input graph H is planar.That makes the illustration of the algorithm easier since the faces of the free-space surface do not intersect except at the boundary of the faces.However, all lemmas and theorems, derived in Section 3 and 4, are proved without making an assumption regarding the planarity of H. Therefore, the algorithm proposed in this paper remains correct for any graph for which a straight-line embedding in a plane is provided (see [5], Section 2.7).In the embedding, the edges of the graph may intersect.Transition from one edge to another is allowed only at a vertex.
We also assumed that H is unweighted.Here, we sketch how the proposed algorithm can be generalized to also handle the problem instance, when H is weighted.Suppose that each edge of H has a non-negative, real weight.A weight could represent the cost of moving on the edge of the graph.The edges of the input polygonal curve T could also have weights capturing the costs of moving forwards and backwards.The objective is to find a path in H whose weighted walking length is minimized.In the weighted problem setting, inside each cell of the free-space surface, there are two weights, one corresponding to an edge of T and one corresponding to an edge of H.These weights are fixed inside the cell and do not change.Therefore, in the construction of G or G , instead of computing the L 1 length for each edge, e, we compute the orthogonal projections of e onto H and T .Then, we multiply the projection lengths with the corresponding weights, and the sum of these multiplications is the weight that we assign to e.The remaining parts of the algorithm remains the same and the time and space complexities do not change.

Conclusion
In this paper, we discussed a geometric algorithm for the map matching problem that minimizes the walking length.We established that this problem setting is dual to a weighted shortest path problem.Then, we proposed an algorithm with O (mn (m + n) log(mn)) time and O (mn (m + n)) space complexities, where m (n, respectively) is the number of edges of H (T , respectively).At the end, we discussed that the proposed algorithm is easily adaptable to handle weighted non-planar graphs.It is still open if we can improve the proposed algorithm further, for planar graphs.The main challenge here is the existence of cycles in the input graph and propagation through the cycles.

Fig. 1 .
Fig. 1.An embedding of a planar graph, H, a polygonal curve, T , and a length ε are given.The path P * = [v1, v3, v4, a, v4, b, v4, v5], in H, is a part of a solution to the map matching problem instance.The edges of H that P * lies on, are illustrated in bold.

Fig. 3 .
Fig.3.The free-space surface for the example of Figure1is drawn from two different viewpoints in 3D.The yellow line segments show the intervals on the cell boundaries.The red dashed polygonal curve is a path on the white-surface that realizes an optimal solution to our problem setting.

Fig. 4 .
Fig. 4. The free-space face F j i is drawn.The endpoints of the intervals, FI j i ( ), are shown by points and the Type 1 Steiner points are shown by squares.

Fig. 5 .
Fig. 5.An example of T j j−1 , for j = 1, is drawn.In this example, there are four intervals that are shown by yellow color.The black balls show the interval endpoints and red balls show the Type 2 Steiner points.

Fig. 6 .
Fig. 6. a) The result of unfolding the sequence of deformed free-space faces that are intersected by the red dashed polygonal curve in Figure 3.It is a 2D free-space diagram, Fε(SF ).The red dashed polygonal curve is shown after unfolding.b) Illustration of case 1 in the proof of Lemma 1.