Bi-Directional Transitive Closure (with dbd)

From: Neo <neo55592_at_hotmail.com>
Date: 1 Dec 2006 09:09:08 -0800
Message-ID: <1164992948.093715.35730_at_n67g2000cwd.googlegroups.com>



Following is a demo of bi-directional transitive closure on a muti-rooted tree using dbd. It represents the following boss/employee hierarchy:

john

   bob

     jack
     bill

mary

   sue

     jack
     bill


(new 'john 'person)
(new 'mary 'person)
(new 'bob 'person)
(new 'sue 'person)
(new 'jack 'person)
(new 'bill 'person)

(new 'boss 'verb)
(new 'employee 'verb)

(set boss leads up)
(set employee leads down)

(set boss reciprocal employee)
(set employee reciprocal boss)

(; Note setWRR automatically creates reciprocal relationship)
(setWRR john employee bob)
(setWRR bob employee jack)
(setWRR bob employee bill)

(setWRR mary employee sue)
(setWRR sue employee jack)
(setWRR sue employee bill)

(; Get john's employees recursively)
(; Gets bob, jack, bill)
(getRel john employee *)

(; Get mary's employees recursively)
(; Gets sue, jack, bill)
(getRel mary employee *)

(; Get jack's bosses recursively)
(; Gets bob, john, sue, mary)
(getRel jack boss *)

(; Get bill's bosses recursively)
(; Gets bob, john, sue, mary)
(getRel bill boss *)
Received on Fri Dec 01 2006 - 18:09:08 CET

Original text of this message