r-tree, r*-tree und r + -tree seminar geoinformation ws 01/02 zugriffstruktur auf mehrdimensionale...

29
R-tree, R*-tree und R + - tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation der Universität Bonn Betreuer: Dipl.-Inform. Ingo Petzold Verfasser: Andreas Joisten

Upload: amalric-schnitzer

Post on 05-Apr-2015

108 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

R-tree, R*-tree und R+-tree

Seminar Geoinformation WS 01/02

Zugriffstruktur auf mehrdimensionale räumliche Objekte

Institut für Kartographie und Geoinformation

der Universität Bonn

Betreuer: Dipl.-Inform. Ingo Petzold

Verfasser: Andreas Joisten

Page 2: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Inhaltsverzeichnis

1. Einleitung

2. Der R-tree

2.1 Struktur und Eigenschaft des R-tree

2.2 Algorithmen des R-tree

2.2.1 Such

2.2.2 Einfüge

2.2.3 Spalt

2.2.4 Lösch

3. R*-tree und R+-tree

- Algorithmus

Page 3: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Einleitung• Anforderung an Zugriffstruktur: multidimensionaler Suchbereich

Versagen des B-Baumes, da eindim. Ordnung der Indexwerte

• Multidimensionale Indexmethode:– Approximation räumlicher Objekte durch kleinste umgebene

„bounding box“– bounding box:

• im 3-D = Quader ; im 2-D = Rechtecke• Lage und Flächeninhalt/Volumen bekannt

– Implementierung: • Zugriff auf Datenobjekte über Pointer • Speicherung der bounding boxen in Zugriffstruktur oder in

Datenobjekten

Page 4: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Struktur des r-tree

R1

R2 R4

R3

B

D

EF

G

C

A

L

MH

I

KJWurzel

R5 R6R3 R4

Wurzel

A B C D E F G H I J K L M N O

N

O

R7

R7

R1 R2

•Wurzel: bounding box, Pointer auf Söhne

Page 5: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Struktur des r-tree

R1

R2 R4

R3

B

D

EF

G

C

A

L

MH

I

KJWurzel

R5 R6R3 R4

Wurzel

A B C D E F G H I J K L M N O

N

O

R7

R7

R1 R2

•Wurzel: bounding box, Pointer auf Söhne

•Innere Knoten: bounding box, Pointer auf Söhne

Page 6: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Struktur des r-tree

R1

R2 R4

R3

B

D

EF

G

C

A

L

MH

I

KJWurzel

R5 R6R3 R4

Wurzel

A B C D E F G H I J K L M N O

N

O

R7

R7

R1 R2

•Wurzel: bounding box, Pointer auf Söhne

•Innere Knoten: bounding box, Pointer auf Söhne

•Blätter: bounding box, Pointer auf Datenobjekt

R1

R2

R3

R4

Page 7: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Festlegungen des r-tree

R1

R2 R4

R3

B

D

EF

G

C

A

L

MH

I

KJWurzel

R5 R6R3 R4

Wurzel

A B C D E F G H I J K L M N O

N

O

R7

R7

R1 R2

•Einträgen pro Knoten

-mindest Anzahl m = 2

-maximale Anzahl M = 4

Page 8: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Eigenschaften des r-tree

R1

R2 R4

R3

B

D

EF

G

C

A

L

MH

I

KJWurzel

R5 R6R3 R4

Wurzel

A B C D E F G H I J K L M N O

N

O

R7

R7

R1 R2

•Die Wurzel hat mind. 2 Söhne außer sie ist ein Blatt

•Jeder Knoten außer der Wurzel besitzt zw. m und M Einträge

•Alle Blätter befinden sich auf derselbe Höhe

Page 9: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Such-Algorithmus

R1

R2 R4

R3

B

D

EF

G

C

A

L

MH

I

KJWurzel

R5 R6R3 R4

Wurzel

A B C D E F G H I J K L M N O

N

O

R7

R7

R1 R2

• Frage: Liegt innerhalb des Suchgebiets eine Stadt?

• Definiere: bounding box des Suchgebiets

Page 10: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Such-Algorithmus

R1

R2 R4

R3

B

D

EF

G

C

A

L

MH

I

KJWurzel

R5 R6R3 R4

Wurzel

A B C D E F G H I J K L M N O

N

O

R7

R7

R1 R2

• Suchgebiet innerhalb aktuellem Knoten ?

Suchgebiet innerhalb Wurzel

Page 11: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Such-Algorithmus

R3

R4 R6

R5

B

D

EF

G

C

A

L

MH

I

KJWurzel

R5 R6R3 R4

Wurzel

A B C D E F G H I J K L M N O

N

O

R7

R7

R1 R2

• Suchgebiet innerhalb aktuellem Knoten ?

Suchgebiet innerhalb R1

Suchgebiet außerhalb R2

Suche im linken Teilbaum

Page 12: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Such-Algorithmus

R3

R4 R6

R5

B

D

EF

G

C

A

L

MH

I

KJWurzel

R5 R6R3 R4

Wurzel

A B C D E F G H I J K L M N O

N

O

R7

R7

R1 R2

• Suchgebiet innerhalb aktuellem Knoten ?

Suchgebiet innerhalb R3

R3

Suchgebiet innerhalb R4

R4

Page 13: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Such-Algorithmus

R3

R4 R6

R5

B

D

EF

G

C

A

L

MH

I

KJWurzel

R5 R6R3 R4

Wurzel

A B C D E F G H I J K L M N O

N

O

R7

R7

R1 R2

• Suchgebiet innerhalb aktuellem Knoten ?

A

B

Suchgebiet innerhalb C

C

D Suchgebiet innerhalb E

EF

G

Page 14: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Such-Algorithmus

Wurzel

R5 R6R3 R4

A B C D E F G H I J K L M N O

R7

R1 R2

E

C

Keine Information in C

Stadt in E

Welches Datenobjekt liegt innerhalb des Suchgebiets?

Page 15: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Einfüge-Algorithmus

R3

R4 R6

R5

B

D

EF

G

C

A

L

MH

I

KJWurzel

R5 R6R3 R4

Wurzel

A B C D E F G H I J K L M N O

N

O

R7

R7

R1 R2

• Zuordnung nach geringstem Flächenzuwachs bzw geringster Fläche der bounding boxen

Z

Zuordnung R1

Page 16: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Einfüge-Algorithmus

R3

R4 R6

R5

B

D

EF

G

C

A

L

MH

I

KJWurzel

R5 R6R3 R4

Wurzel

A B C D E F G H I J K L M N O

N

O

R7

R7

R1 R2

• Zuordnung nach geringstem Flächenzuwachs bzw geringster Fläche

Z

Zuordnung R3

überlauf des Blattes

Page 17: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Spalt-Algorithmus

• Aufgabe: Verteilung der M + 1 Einträge auf zwei neue Knoten

• Wichtig: Struktur des r-tree von der Gestaltung der neuen Knoten abhängig

• worse case: zufällige Zuordnung der Einträge Überlagerung der bounding boxen schlechte Suche

• Systematische Zuordnung: entfernungsabhängiges Einfügen der Einträge

Page 18: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Aufspalten eines Knotens/Blattes

R3

B

D

C

A

Wurzel

R5 R6R3 R4

A B D E F G H I J K L M N O

R7

R1 R2

Z

Z

•Suche: 2 Einträge, die die neuen Blätter festlegen

•Forderung: 2 Einträge mit max. Abstand

C

CB

B

C

A

A

Z

Z

R‘3 := A und R‘‘3 := Z

Page 19: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

C

Aufspalten eines Knotens/Blattes

R3

D

C

A

Wurzel

R5 R6R3 R4

A B D E F G H I J K L M N O

R7

R1 R2

Z

Z

A

A

Z

Z

F_AB und F_ZB

•Ziel: Flächenzuwachs der verbleibenden Einträgen zu A , Z B

B

B

Page 20: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

C

Aufspalten eines Knotens/Blattes

R3

C

A

Wurzel

R5 R6R3 R4

A B D E F G H I J K L M N O

R7

R1 R2

Z

Z

A

A

Z

Z

•Ziel: Flächenzuwachs der verbleibenden Einträgen zu A , Z B

C

C

D

Page 21: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

C

Aufspalten eines Knotens/Blattes

R3

C

A

Wurzel

R5 R6R3 R4

A B D E F G H I J K L M N O

R7

R1 R2

Z

Z

A

A

Z

Z

•Ziel: Flächenzuwachs der verbleibenden Einträgen zu A , Z B

DD

D

Page 22: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

C

Aufspalten eines Knotens/Blattes

R3

C

A

Wurzel

R5 R6R3 R4

A B D E F G H I J K L M N O

R7

R1 R2

Z

Z

A

A

Z

Z

B

D

•Ziel: je geringer der Abstand eines Daten- objekts zu den Ursprungselementen, desto eher das Einfügen

•Ansatz: Flächendifferenzen F_AB – F_ZB = DB

Reihenfolge des Einfügens nach größter Flächendifferenz

Page 23: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Neue Struktur des R-tree

R4 R6

R5

B

D

EF

G

C

A

L

MH

I

KJWurzel

R5 R6R‘‘3 R4

Wurzel

A B C Z E F G H I J K L M N O

N

O

R7

R7

R1 R2

Z

D

R‘3

R‘3

R‘‘3

Page 24: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

R4 R6

R5

B

D

EF

G

C

A

MH

I

KJWurzel

R5 R6R‘‘3 R4

Wurzel

A B C Z E F G H I J K M N O

N

O

R7

R7

R1 R2

Z

D

R‘3

R‘3

R‘‘3

Lösch-Algorithmus

• Lösche: L L

L M

R6

R6 kann nicht existieren

• bounding box verkleinern

• Such-Algorithmus

L

• Datenobjekt löschen

L

Page 25: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

R4

R5

B

D

EF

G

C

A

MH

I

KJWurzel

R5 R7R‘‘3 R4

Wurzel

A B C Z E F G H I J K M N O

N

O

R7

R1 R2

Z

D

R‘3

R‘3

R‘‘3

Lösch-Algorithmus

•Löschen u. wiedereinfügen von M

kleinerer Flächenzuwachs zu R7

Page 26: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

R4

R5

B

D

EF

G

C

A

MH

I

KJWurzel

R5 R7R‘‘3 R4

Wurzel

A B C Z E F G H I J K M N O

N

O

R7

R1 R2

Z

D

R‘3

R‘3

R‘‘3

Neue Struktur des R-tree

Page 27: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

Optimierungen bei dem R-tree

•Reduktion der Überlappungen weniger Suchpfade

Überlappung

•Freifläche der bounding box minimieren bessere Approximation durch bounding box

Feifläche

•Maximierung der Anzahl der Einträge Reduzierung der Höhe

Page 28: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

R*-tree

• R*-tree als Fortführung des R-tree

– Kriterium des R-tree: geringster Flächenzuwachs– Kriterien des R*-tree:

• Innere Knoten nach geringsten Flächenzuwachs• Blätter nach geringster Überlappung der bounding boxen

• Verbesserung der Suchperformance:

– Änderung der Einfüge- u. Teilungsstrategien– Einführung des erzwungenen Wiedereinfügens

Page 29: R-tree, R*-tree und R + -tree Seminar Geoinformation WS 01/02 Zugriffstruktur auf mehrdimensionale räumliche Objekte Institut für Kartographie und Geoinformation

R+-tree

DF

K

J

DF

H

K

JH

BA

FD G JH K

CA

FD G HG

B

JK

•Keine Überlappung der Inneren Knoten

R-tree R+-tree

G G GG G GA A

B B

C