This preview shows page 1. Sign up to view the full content.
Unformatted text preview: Rpath iff there is a subsequence
o j1
o jK (K 1) of p such that for each i, o ji has type ci , and jK N (that is,
the last element of the path must be part of the subsequence). We say an Rpath is
minimal iff it has no initial segment that is also an Rpath.
$ ©222
333© $ ¨ $ ©222
4333© ¨ ©222
5333© Thus an Rpath is a path through the object graph that passes through objects
of the types speciﬁed by R in the order speciﬁed by R. It may pass through objects
of other classes along the way, but it must end at the endpoint of R.
Given an object o, we can visit all the endpoints of minimal Rpaths starting at
o as follows:
Algorithm search o R :
cn . ©222
333© c1 $
¨ © ¨ Let c1 , . . . , cn be the classes such that R 1. If o does not have type c1 , then for each e in FIRST class o c1 ,
and each o such that e o o , do search o R .
© ¨ ¨ ©£
£ ¨ c1 , then do visit o .
©222
4333© ¨
5© ¨ ©222
333© © 5 cn , then do search o c2 cn .
3 ¨ £ ¨ $
¨ c1 c2 © ¨ $ 3. If o has type c1 , and R 2. If o has type c1 , and R In case 1 we are not yet on a path, so we follow the FIRST edges to guide us to
the ﬁrst goal type c1 . We can ﬁnd the required objects o by retrieving the value of
o’s eﬁeld. In case 2, we have reached the last goal type, so we visit the object. In
case 3 we have reached the ﬁrst goal type, so we recur on the rest of the goal path.
£ We could ﬁnd all Rpaths, by modifying step 2 to continue searching:
2 If o has type c1 , and R
c1 , then do visit o . Then for each e in
FIRST class o c1 , and each o such that e o o , do search o R .
©£
6£ ¨ © ¨ $ ¨ £ £ ¨ © ¨ ¨ If the object graph is acyclic, these algorithms will always terminate, since every step either decreases the longest chain of links in the object graph or decreases
the length of R. If the graph may be cyclic, then we need to mark each searched
object with the state R in which it was reached, or else carry around the set of pairs
o R that we have already searched. This will allow us to avoid repeated visits to
the same object in the same traversal state.
© ¨ DJ allows the use of a graph, called a strategy graph, to specify a more complex
traversal [10]. A strategy graph can be modeled as a nondeterministic ﬁnitestate
automaton:
Deﬁnition 4 A strategy graph is given by a set of states Q, a relation S on states, a
map class : Q C, a set QI Q of initial states, and a set QF Q of ﬁnal states.
We denote such a strategy graph by S.
7 7 ! o1
oN in O is an Spath iff there is a subsequence
Deﬁnition 5 A path p
o j1
o jK (K 1) of p and a path q1
qK in S such that for each i, o ji has
type class qi , jK N, and qK QF. As before, we say that an Spath is minimal
iff it has no initial segment that is also an Spath.
©222
5333© ©222
333© $ ¨ ¨ ©222
533...
View
Full
Document
This document was uploaded on 03/17/2014 for the course CSG 111 at Northeastern.
 Fall '09

Click to edit the document details