a generic data structure for representing discrete paths
play

A generic data structure for representing discrete paths on regular - PowerPoint PPT Presentation

A generic data structure for representing discrete paths on regular grids e and Alexandre Blondin Mass E. Marcotte LaCIM Universit e du Qu ebec ` a Montr eal June 4th, 2016 GASCom 2016 Blondin Mass e and Marcotte (LaCIM,


  1. A generic data structure for representing discrete paths on regular grids e and ´ Alexandre Blondin Mass´ E. Marcotte LaCIM Universit´ e du Qu´ ebec ` a Montr´ eal June 4th, 2016 GASCom 2016 Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 1 / 26

  2. Discrete paths (a) (b) (c) Three discrete paths : ◮ (a) simple ; ◮ (b) nonsimple ; ◮ (c) closed and simple . Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 2 / 26

  3. Simple paths (self-avoiding walks) Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 3 / 26

  4. Some questions Given some discrete path ... ◮ ...is it simple ? ◮ ...how many intersection points does it have? Given two discrete regions (closed paths)... ◮ ...what is their intersection ? ◮ ...what is their union ? ◮ ...what is their difference ? More generally, how efficiently can we answer these questions? Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 4 / 26

  5. Solution 1: balanced tree/sorting ◮ We walk along the path, step by step ; ◮ We insert the points in a balanced tree ; ◮ If there is an intersection, it is immediately detected since the point already belongs to the tree; ◮ Complexity? ◮ O ( n log n ) time; ◮ O ( n ) space; ◮ Similarly, it is possible to store all points in a list and then sort it, yielding the same complexities . Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 5 / 26

  6. Solution 2: boolean matrix ◮ Using a boolean matrix , we can also mark the visited points; ◮ Let w and h be the width and height of the bounding box of the path; ◮ Then we have the following complexities : ◮ O ( n ) time; ◮ O ( wh ) space. ◮ It is of course easy to build examples where w, h ∈ Ω( n ), so that the space complexity is then Θ( n 2 ). Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 6 / 26

  7. Solution 3: hash table ◮ We mark the visited points with a hash table ; ◮ It is well-known that hash tables have O (1) average complexity per operation; ◮ However, there is no guarantee of having O (1) in the worst case . ◮ Complexity? ◮ Time : depends on the quality of the hash function; ◮ Space : depends on the capacity of the hash table. ◮ Since the distribution of discrete paths is quite complexe, it is hard to image a function with guaranteed perfect hashing . Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 7 / 26

  8. Solution 4: linear sorting ◮ In some cases, one can sort in linear time : ◮ Bucket sort; ◮ Counting sort; ◮ Radix sort. ◮ In our case, it suffices to sort the points according to their x -coordinate and then their y -coordinate (using the radix sort ); ◮ Complexity? ◮ Time : Θ( n ); ◮ Space : Θ( n ). ◮ However, intersection points cannot be detected online . Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 8 / 26

  9. Brlek, Koskas and Proven¸ cal’s data structure ◮ S. Brlek, M. Koskas, X. Proven¸ cal, A linear time and space algorithm for detecting path intersection in Z d , Theoretical Computer Science (TCS) 412 , 2011, p. 4841-4850; ◮ The authors introduce a data structure called enriched radix tree , which allows the detection of self-intersection efficiently. ◮ As a first step, we present it for the N 2 grid, then we discuss how it can be extended to Z 2 , as well as other grids . Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 9 / 26

  10. The radix relation ◮ The radix relation on N 2 is defined by ( x, y ) → ( x ′ , y ′ ) ⌊ x ′ / 2 ⌋ , ⌊ y ′ / 2 ⌋ � � if and only if ( x, y ) = ◮ Clearly, → is a strict order relation; ◮ ( x, y ) is called the parent of ( x ′ , y ′ ); ◮ ( x ′ , y ′ ) is called the child of ( x, y ); ◮ It may be seen as a 2D generalization of the heap order for arrays: 1 2 3 4 5 6 7 8 9 10 16 14 10 8 7 9 3 2 4 1 Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 10 / 26

  11. Combining two relations on N 2 (a) (b) ◮ (a) The radix (strict) order; ◮ (b) The 4 -adjacency relation; ◮ We need to understand how those two relations interact . Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 11 / 26

  12. Observation 1 Lemma (Reformulation of BKP, 2011) If p, p ′ ∈ N 2 are neighbors , then exactly one of those two conditions is verified: (i) p and p ′ are siblings , i.e. parent ( p ) = parent ( p ′ ); (ii) parent ( p ) and parent ( p ′ ) are neighbors . Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 12 / 26

  13. Observation 2 Lemma (Reformulation of BKP, 2011) Let p, p ′ ∈ Z 2 be two nonsibling neighbor points. Then parent ( p ′ ) = parent ( p ) + # » d , d = # » pp ′ ∈ { (1 , 0) , (0 , 1) , ( − 1 , 0) , (0 , − 1) } . where # » Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 13 / 26

  14. Basic idea As we travel along the discrete path, we add ◮ a vertex for each new visited point; ◮ undirected edges between some of the neighbor points; ◮ directed edges between some of the points related by the parent/child relation ; Then 1. We start at the origin ; 2. We read the next move, which points toward of the four possible neighbors of the current point; 3. We find this neighbor in the data structure, adding whatever vertex or edge that is needed; 4. We repeat steps 2-3 as long as the discrete path has not been completely traveled. Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 14 / 26

  15. Example Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 15 / 26

  16. Example Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 15 / 26

  17. Example Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 15 / 26

  18. Example Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 15 / 26

  19. Example Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 15 / 26

  20. Example Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 15 / 26

  21. Example Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 15 / 26

  22. Example Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 15 / 26

  23. Example Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 15 / 26

  24. Example Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 15 / 26

  25. Example Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 15 / 26

  26. Example Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 15 / 26

  27. Example Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 15 / 26

  28. Pseudocode (1/3) 1: function DiscretePathGraph (): discrete path graph u ← Node () 2: u .point ← (0 , 0) 3: u .parent ← u 4: u .visited ← true 5: G .current node ← u 6: return G 7: 8: end function 9: 10: procedure Move ( G : radix tree, d : direction) next node ← Neighbor ( G. current node , d ) 11: ⊲ Do something with next node and current node 12: G. current node ← next node 13: 14: end procedure Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 16 / 26

  29. Pseudocode (2/3) 1: function Neighbor ( u : node, d : direction): node if u .neighbor[ d ] is not defined then 2: p ← u. point 3: p ′ ← p + d 4: if parent ( p ) = parent ( p ′ ) then 5: v ← Child ( u. parent , d ) 6: else 7: d ′ ← parents direction( p, p ′ , d ) 8: v ← Child ( Neighbor ( u. parent , d ′ ) , d ) 9: end if 10: u. neighbor[ d ] ← v 11: v. neighbor[ − d ] ← u 12: end if 13: return u .neighbor[ d ] 14: 15: end function Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 17 / 26

  30. Pseudocode (3/3) 1: function Child ( u : node, d : direction): node if u .child[ i ] is not defined then 2: v ← Node () 3: i ← child index( d ) 4: v .point ← child coordinates( u. point , d ) 5: u .child[ i ] ← v 6: v .parent ← u 7: v .visited ← false 8: end if 9: return u .child[ i ] 10: 11: end function Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 18 / 26

  31. The 4-step lemma Lemma (BKP, 2011) Let γ be a discrete path of length 4 and p i the i -th point of N 2 visited by γ , for 0 ≤ i ≤ 4. Then there exists a least two distinct indices j and j ′ such that p j and p j ′ are siblings . Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 19 / 26

  32. Complexity ◮ It is proportional to the number of vertices in the graph, since the number of neighbor edges and parent/child edges is bounded by a constant ; ◮ But, � 0 ≤ i ≤ h, p ∈ points ( γ ) � points (parent i ( p )) � � points ( G ) = . where h is the height of the tree. ◮ Therefore, � 4 � i | points (parent i ( p )) | ≤ | points ( p ) | 5 and � 4 h ∞ � i � � | points (parent i ( p )) | ≤ � | points ( G ) | = n = 5 n = O ( n ) . 5 p ∈ points ( γ ) i =0 i =0 ◮ The amortized complexity of Move () is O ( n ) /n = O (1). Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 20 / 26

  33. Other grids (1/3) (a) (b) (c) ◮ (a) 4-regular; ◮ (b) 6-regular; ◮ (c) 8-regular (nonplanar). Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 21 / 26

  34. Other grids (2/3) ◮ The 4-step lemma does not hold ! Blondin Mass´ e and Marcotte (LaCIM, UQAM) June 4th, 2016 22 / 26

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend