Re: Network Example: Sibling of Opposite Gender
Date: 30 Dec 2006 19:34:21 -0800
Message-ID: <1167536061.214435.108690_at_v33g2000cwv.googlegroups.com>
> I admit I haven't been following this thread too closely, but > I have to ask: can you be more specific about...
The names given to nodes and relationships are just for the sake of convenience. The problem can be described in terms of node1, node2, relationship1, etc. Because people are having trouble accepting that a person's gender can have more that two values or the need to specify opposites, I have renamed them to something more appropriate.
Suppose Adam(30) has children named John(tall), Mary(short), Bob(fat), Sue(short/thin), Adam(5). Builds tall/short and fat/thin are opposites. We want to find the following, without explicitly referring to John's parent (Adam) or John's build (tall) directly:
1) John's siblings. 2) John's fat siblings. 3) John's siblings of opposite build. 4) Persons with builds with whom Bob's build has same relationship asJohn's build's relationship with Mary's build (without explicitly referring to that relationship in the query). Below dbd script implements the above example.
(new 'tall 'build)
(new 'athletic 'build)
(new 'petite 'build)
(new 'short 'build)
(new 'thin 'build)
(new 'fat 'build)
(new 'opposite)
(set tall opposite short)
(set short opposite tall)
(set fat opposite thin)
(set thin opposite fat)
(new 'john 'person)
(set john build tall)
(new 'mary 'person)
(set mary build short)
(new 'bob 'person)
(set bob build fat)
(new 'sue 'person)
(set sue build short)
(set sue build thin)
(new 'age)
(new 'adam 'person)
(set+ adam age '10)
(new 'adam 'person)
(set+ (it) age '30)
(set (it) child john)
(set (it) child mary)
(set (it) child bob)
(set (it) child sue)
(set (it) child (and (get * name 'adam)
(get * age 10)))
(; Get john's siblings
by getting persons
who are children of john's parent
and are not himself)
(; Gets mary, bob, sue, little adam)
(!= (and (get person instance *)
(get (get * child john) child *)) john)
(; Get john's fat siblings
by getting persons
whose build is fat
and are children of john's parent
and are not himself)
(; Gets bob)
(!= (and (get person instance *)
(get * build fat) (get (get * child john) child *))john)
(; Get john's siblings of opposite build
by getting persons
whose build is opposite of john's build
and are children of john's parent
and are not himself)
(; Gets mary and sue)
(!= (and (get person instance *)
(get * build (get (get john build *) opposite *)) (get (get * child john) child *))john)
(; Get persons with builds with whom bob's build relationship is the
same as
john's build relationship to mary's build)
(; Gets sue)
(get * build (get (get bob build *)
(get (get john build *) * (get mary build *)) *))Received on Sun Dec 31 2006 - 04:34:21 CET