Mitch Wand - PowerPoint PPT Presentation

About This Presentation
Title:

Mitch Wand

Description:

Search using meta information. we could visit the entire object but ... the object graph cannot contain more information than the class graph allows. ... – PowerPoint PPT presentation

Number of Views:56
Avg rating:3.0/5.0
Slides: 56
Provided by: karllie
Category:
Tags: lead | mitch | wand

less

Transcript and Presenter's Notes

Title: Mitch Wand


1
Navigation in Object Graphs
  • Mitch Wand
  • and
  • Karl Lieberherr

2
Searching for Reachable Objects
  • Task Given an object o1 of class c1 in an object
    graph, find all objects of type c2 that are
    reachable from o1.
  • Assumptions we know the class structure that
    describes the object graph, but we know nothing
    else about the object graph except the class of
    the current object.

3
Search using meta information
  • we could visit the entire object but that
  • would be wasteful or
  • might lead to wrong results

4
Classes and Objects Basic Notations
e
c2
c1
Class c1 has a part e of type c2
c2
c1
Class c1 inherits from class c2
c1
o1c1
Object o1 is of class c1
c1
o1c1
c2
Object o1 is of type c2 (i.e., its class is a
subclass of c2)
e
o2
o1
Object o1 has a part e which is object o2
5
Finding the first step for the search
C1
C2
ObjectGraph-object
o2
o1C1
o4
o3
Which arrows might lead to an object of type C2?
Traversal Strategy from C1 to C2
6
Relations between Classes
e
C2
C1
e(C1,C2)
C2
C1
C(C1,C2) (that is, e(C1,C2) for some e)
C2
C1
lt(C1,C2), gt(C2,C1)
C1
o1C1
Class(o1) C1
C1
o1C1
C2
Object o1 is of type C2 Class(o1) lt C2
7
Relations between Objects
e
o2
o1
e(o1,o2)
o2
o1
O(o1,o2) (that is, e(o1,o2) for some e)
8
Operations on Relations
  • R.S (x,z) exists y s.t. R(x,y) and S(y,z)
  • R reflexive, transitive closure of R

9
Write graph in terms of relations
Set S,T,X1,X2,X3,Y1,Y2,Y3,Z1,Z2,Z3
Relations are sets of pairs, ordering is
irrelevant.
Relations x,y,z,t,lt,gt x(S,X1) y(X2,Y2) z(
Y1,Z1) t(Z2,T) lt(Y2,Y1) lt(X2,X1) lt(X3,X2) gt(
X2,X3) gt(X1,X2) gt(Z1,Z2)
z
x
X1
Y1
Z1
T
y
t
X2
S
Y2
Z2
X3
Y3
Z3
Compose x and gt
10
Possible edges in the object graph
e
C1
C2
e(o1, o2) implies class(o1) (lt .e .gt )
class(o2) in the class graph

up, over, and down
O(o1, o2) implies class(o1) (lt .C .gt )
class(o2) in the class graph
e
o1
o2
11
Which edges to follow to C2?
C2
  • From o1 of class C1, follow edge e iff there is
    some object graph O and some o2, o3 s.t.
  • e(o1,o2),
  • O(o2,o3), and
  • class(o3) lt C2

C1
o1C1

o3
o2
e
The existential quantifier there is some object
graph represents our lack of knowledge about the
rest of the object graph
12
Example
from Basket to Orange
f
Fruit
Basket
Orange
class graph
v
Vegetable
Apple
premature termination
f
a1Apple
f
b1Basket
b1Basket
v
object graph
v1Vegetable
object graph slice
13
Example
from Basket to Orange
mapping o1 b1 o2 a1 o3 a1 e f
f
Fruit
Basket
Orange
class graph
v
Vegetable
Apple
f
a1Orange
b1Basket
object graph
v
object graph slice
v1Vegetable
14
Example B1
strategy
From A via T to D
0..1
X
B
0..1
D
A
C
0..1
D
C
R
S
T
a1A
0..1
class graph
object graph
r1R
s1S
15
Example B1
strategy
From A via T to D
0..1
X
B
0..1
D
A
C
0..1
object graph slice
D
C
R
S
T
a1A
0..1
class graph
object graph
r1R
s1S
16
Example B2
strategy
From A via T to D
a1A
0..1
D
r1R
X
B
0..1
c1C
s1S
D
A
C
s2S
t1T
0..1
r2R
object graph
R
S
T
0..1
c2C
class graph
d2D
17
Example B2
strategy
From A via T to D
object graph slice
a1A
0..1
D
r1R
X
B
0..1
c1C
s1S
D
A
C
s2S
t1T
0..1
r2R
object graph
R
S
T
0..1
c2C
class graph
d2D
18
Lack of Knowledge
  • Objects of a given class may be very different.
  • We want to go down edges without looking ahead!
  • We dont want to go down edges that are
    guaranteed to be unsuccessful (never reaching a
    target object).

19
Object graph conforms to class graph
  • The object graph O must follow the rules of the
    class graph the object graph cannot contain more
    information than the class graph allows.

For all edges e(o1,o2) in the object graph e(o1,
o2) implies class(o1) (lt .e .gt ) class(o2)
in the class graph
20
From dynamic to static characterization
  • From o1 of class c1, follow edge e iff there is
    some object graph O and some o2, o3 s.t.
  • e(o1,o2),
  • O(o2,o3), and
  • class(o3) lt c2
  • From o1 of class c1, follow edge e iff there are
    classes c, c s.t.
  • c1 lt.e.gt c
  • c (lt.C.gt) c and
  • c lt c2

Let c be class(o2), c be class(o3)
21
Example
static characterization
from Basket to Orange
f
Fruit
Basket
Orange
class graph
v
Vegetable
Apple
premature termination
f
a1Apple
f
b1Basket
b1Basket
v
object graph
v1Vegetable
object graph slice
22
Example
static characterization
from Basket to Orange
mapping c1 Basket c Orange c Orange e f
f
Fruit
Basket
Orange
class graph
v
Vegetable
Apple
f
a1Orange
b1Basket
object graph
v
object graph slice
v1Vegetable
23
Relational Formulation
from x1 to x2
From object o of class x1, to get to x2, follow
edges in the set POSS(x1,x2)e x1
lt.e.gt.(lt.C.gt).lt x2
Can easily compute these sets for every x1, x2
via transitive-closure algorithms. POSS
abbreviation for following these edges it is
still possible to reach a x2-object for some
x1-object rooted at o.
24
Negative formulation
Positive Formulation From object o of class x1,
to get to x2, follow edges e in the set
POSS(x1,x2)e x1 lt.e.gt.(lt.C.gt).lt x2
Build paths anyway you like but dont follow gt
(down) immediately after lt (up) and the first
has-a edge must have label e.
Edge kinds Is-a (down, up) Has-a
ok
down
up
down
up
Forbidden
ok
25
Followed-by relationships
26
Linking the terminologies
27
Generalizations
  • More complex strategies
  • from c1 through c2 to c3
  • Use waypoint navigation get to a c2 object,
    then search for a c3 object.
  • More complex strategy graphs also doable in this
    framework

28
Cyclic and acyclic object graphs
  • If the object graph is acyclic, algorithm search
    will terminate, since every step either decreases
    the longest chain of links in the object graph or
    decreases the length of R.
  • If the object graph is cyclic, then we need to
    mark each searched object with the state R in
    which it was reached (to not visit it again in
    the same state).

29
Examples
30
Example A
z
Strategy S -gt T
x
X1
Y1
Z1
T
Relations x(S,X1) gt(X1,X2) y(X2,Y2) lt(Y2,Y1) z(
Y1,Z1) gt(Z1,Z2) t(Z2,T) lt(X2,X1) lt(X3,X2) gt(X2
,X3)
t
y
X2
S
Y2
Z2
X3
Y3
Z3
x
y
z
t
x31X3
y31Y3
z31Z3
t1T
s1S
go down x iff S and T are in relation lt.x.
gt.(lt.C.gt).lt
31
Example A
z
Strategy S -gt T
x
X1
Y1
Z1
Relations x(S,X1) gt(X1,X2) y(X2,Y2) lt(Y2,Y1) z(
Y1,Z1) gt(Z1,Z2) t(Z2,T) lt(X2,X1)
T
t
y
X2
S
Y2
Z2
X3
Y3
Z3
x
y
z
t
x31X3
y31Y3
z31Z3
t1T
s1S
lt,gt not used
go down x iff S lt.x. gt.(lt.C.gt).lt T
32
Example A
z
Strategy S -gt T
x
X1
Y1
Z1
T
Relations x(S,X1) gt(X1,X2) y(X2,Y2) lt(Y2,Y1) z(
Y1,Z1) gt(Z1,Z2) t(Z2,T) lt(X2,X1)
y
t
X2
S
Y2
Z2
X3
Y3
Z3
x
y
z
t
x31X3
y31Y3
z31Z3
t1T
s1S
lt,gt not used
go down x iff S lt.x. gt.(lt.C.gt.lt.C.gt.lt.Cgt).
lt T
33
Just in terms of relations
Relations are sets of pairs, ordering is
irrelevant.
z
x
X1
Y1
Z1
T
y
t
X2
S
Y2
Z2
X3
Y3
Z3
Set S,T,X1,X2,X3,Y1,Y2,Y3,Z1,Z2,Z3
34
Write graph in terms of relations
Set S,T,X1,X2,X3,Y1,Y2,Y3,Z1,Z2,Z3
Relations are sets of pairs, ordering is
irrelevant.
Relations x,y,z,t,lt,gt x(S,X1) y(X2,Y2) z(
Y1,Z1) t(Z2,T) lt(Y2,Y1) lt(X2,X1) lt(X3,X2) gt(
X2,X3) gt(X1,X2) gt(Z1,Z2)
z
x
X1
Y1
Z1
T
y
t
X2
S
Y2
Z2
X3
Y3
Z3
35
Compose relations
Set S,T,X1,X2,X3,Y1,Y2,Y3,Z1,Z2,Z3
Relations are sets of pairs, ordering is
irrelevant.
inheritance in reverse
Relations x,y,z,t,lt,gt x(S,X1) y(X2,Y2) z(Y1,Z1)
t(Z2,T) lt(Y2,Y1) lt(X2,X1) lt(X3,X2) gt(X2,X3)
gt(X1,X2) gt(Z1,Z2)
inheritance
Are S and T in the relation lt.x.
gt.(lt.C.gtlt.C.gt.lt.Cgt).lt
36
Just in terms of relations
Set S,T,X1,X2,X3,Y1,Y2,Y3,Z1,Z2,Z3
Relations are sets of pairs, ordering is
irrelevant.
The order in which we consume the pairs
Relations x,y,z,t,lt,gt x(S,X1) y(X2,Y2) z(Y1,Z1)
t(Z2,T) lt(Y2,Y1) lt(X2,X1) lt(X3,X2) gt(X2,X3)
gt(X1,X2) gt(Z1,Z2)
Relations x(S,X1) gt(X1,X2) y(X2,Y2) lt(Y2,Y1) z(
Y1,Z1) gt(Z1,Z2) t(Z2,T)
go down x iff S lt.x. gt.(lt.C.gtlt.C.gt.lt.Cgt).lt
T
37
How big is the relation?
How many pairs does the relation contain in this
example?
lt.x. gt.(lt.C.gtlt.C.gt.lt.Cgt).lt
38
What is disallowed?
E
Where can you go from A?
e
A
B
x
D
C
go down x iff S and T are in relation lt.x.
gt.(lt.C.gt).lt
39
Example B
class dictionary
strategy
A x X r R. B b B D. R S. S
t T C C D. X B. T R. D .
A -gt T T -gt D
0..1
POSS(x1,x2)e x1 e.C x2
X
B
0..1
D
A
C
0..1
D
C
R
S
T
A
0..1
class graph
object graph r
R
S
40
Example B1
class dictionary
strategy
A x X r R. B b B D. R S. S
t T C C D. X B. T R. D .
A -gt T T -gt D
POSS(A,T) 1 edge POSS(R,T) 1 edge POSS(S,T)
0 edges
0..1
X
B
0..1
D
A
C
0..1
D
C
R
S
T
a1A
0..1
class graph
object graph r
r1R
s1S
POSS(c1,c2)e c1 e.C c2
41
Example B1
class dictionary
strategy
A x X r R. B b B D. R S. S
t T C C D. X B. T R. D .
A -gt T T -gt D
POSS(A,T) 1 edge POSS(R,T) 1 edge POSS(S,T)
0 edges
0..1
X
B
0..1
D
A
C
0..1
object graph slice
D
C
R
S
T
a1A
0..1
class graph
object graph r
r1R
s1S
POSS(c1,c2)e c1 e.C c2
42
Example B2
strategy
POSS(A,T) 1 edge POSS(R,T) 1 edge POSS(S,T)
1 edge POSS(T,D) 1 edge POSS(R,D) 1 edge
A -gt T T -gt D
object graph slice
a1A
0..1
D
r1R
X
B
0..1
c1C
s1S
D
A
C
s2S
t1T
0..1
object graph r t
r2R
R
S
T
0..1
c2C
class graph
d2D
POSS(c1,c2)e c1 e.C c2
43
Example C
Only node paths shown for space reasons
strategy SG A -gt B B -gt C
Object graph
Strategy s
t
A
A
B
C
x1X
class graph
S
e1Empty
R
R
A
x2X
B
Empty
x
c
x
c1C
X
b
OG A X R X C OG A X B X C SG A
B C
c2C
BOpt
c
c3C
C
44
Example C
Write Java code that does the traversal
strategy A -gt B B -gt C
Object graph
Strategy s
t
A
A
B
C
x1X
class graph
S
e1Empty
R
R
A
x2X
B
Empty
x
c
x
c1C
X
b
c2C
BOpt
c
c3C
C
45
Example C
Not the complete story
strategy A -gt B B -gt C
Object graph
From A to B
Strategy s
t
A
A
B
C
x1X
class graph
S
e1Empty
R
R
A
x2X
B
Empty
x
c
x
c1C
X
b
From B to C
c2C
BOpt
c
c3C
C
46
Example C
Not the complete story traversal must look for
further B
strategy A -gt B B -gt C
Object graph
From A to B
Strategy s
t
A
A
B
C
x1X
class graph
S
e1Empty
R
R
A
x2X
B
Empty
x
c
x
c1C
X
b
From B to C
c2C
BOpt
c
c3C
C
47
Example C
Not the complete story traversal must look for
further B
strategy A -gt B B -gt C
Object graph
From A to B
Strategy s
t
A
A
B
C
First B found
x1X
class graph
S
e1Empty
R
R
A
x2X
B
Empty
x
c
x
c1C
X
b
Premature Termination No more B
c2C
BOpt
c
c3C
C
48
Example C1
Only node paths shown for space reasons
strategy SG A -gt S S -gt C
Object graph
early termination
Strategy s
t
A
A
S
C
x1X
class graph
S
e1Empty
R
R
A
x2X
B
Empty
x
c
x
c1C
X
b
OG A X R X OG A X B X SG A
B CG A X Bopt B X
c2C
BOpt
c
c3C
C
49
Example D
S from BusRoute through Bus to Person
busStops
BusRoute
BusStopList
buses
0..
BusStop
NGasPowered
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
DieselPowered
50
Example D1
OG BR BL DP PL P OG BR BL B PL P S BR
B P
Only node paths shown for space reasons
BusList
Route1BusRoute
buses
busStops
BusStopList
Bus15DieselPowered
passengers
CentralSquareBusStop
waiting
PersonList
PersonList
JoanPerson
PaulPerson
SeemaPerson
EricPerson
S from BusRoute through Bus to Person
51
Example D2
OG BR BL OG BR BL S BR
Only node paths shown for space reasons
early termination
BusList
Route1BusRoute
buses
busStops
BusStopList
Bus15DieselPowered
passengers
CentralSquareBusStop
waiting
PersonList
PersonList
JoanPerson
PaulPerson
SeemaPerson
EricPerson
S from BusRoute via NGasPowered to Person
52
Relational Formulation
from c1 bypassing x1,x2, ,xn to c2
From object o of class c1, to get to c2, follow
edges in the set POSS(c1,c2)e c1 lt.e.gt
(lt.C.gt) lt c2
POSS abbreviation for following these edges it
is still possible to reach a c2-object for some
c1-object rooted at o.
Delete x1,x2, ,xn and all edges incident with
these nodes from the class graph (assumed to be
different from c1, c2).
53
Example D
S from BusRoute bybassing Bus to Person
busStops
BusRoute
BusStopList
buses
0..
BusStop
NGasPowered
BusList
waiting
0..
passengers
Bus
PersonList
Person
0..
DieselPowered
54
Example D
S from BusRoute bybassing Bus to Person
busStops
BusRoute
BusStopList
buses
0..
BusStop
NGasPowered
BusList
waiting
PersonList
Person
0..
DieselPowered
55
Conclusions
  • Programming language elements are mathematical
    objects having precise mathematical definitions.
  • Exercise in applying an abstract algorithm to
    concrete inputs. Mapping abstract situations to
    concrete situations.
  • Separation of concerns is also useful for
    defining programming language elements
  • separate subgraph selected from
  • how the subgraph is traversed (depth-first etc.)
  • In earlier works meaning of a traversal strategy
    for an object graph
  • was a traversal history
  • now it is a subgraph of the object graph. A
    traversal history can be defined ...
Write a Comment
User Comments (0)
About PowerShow.com