Lecture 6 Notes

We say an r path is minimal iff it has no initial

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: R-path 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 R-path is minimal iff it has no initial segment that is also an R-path. $  ©222 333© $ ¨  $ ©222 4333© ¨ ©222 5333© Thus an R-path is a path through the object graph that passes through objects of the types specified by R in the order specified 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 R-paths 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 first goal type c1 . We can find the required objects o by retrieving the value of o’s e-field. In case 2, we have reached the last goal type, so we visit the object. In case 3 we have reached the first goal type, so we recur on the rest of the goal path. £ We could find all R-paths, 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 non-deterministic finite-state automaton: Definition 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 final states. We denote such a strategy graph by S. 7 7 ! o1 oN in O is an S-path iff there is a subsequence Definition 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 S-path is minimal iff it has no initial segment that is also an S-path.   ©222 5333© ©222 333© $ ¨ ¨ ©222 533...
View Full Document

This document was uploaded on 03/17/2014 for the course CSG 111 at Northeastern.

Ask a homework question - tutors are online