| Oracle FAQ | Your Portal to the Oracle Knowledge Grid | |
Home -> Community -> Usenet -> comp.databases.theory -> Re: transitive closure of a graph
Serge Rielau wrote:
> Mikito Harakiri wrote:
> > Mikito Harakiri wrote:
> >
> >>Transitive closure (TC) of a graph is
> >>
> >>with TransClosedEdges (tail, head) as
> >>( select tail, head from Edges
> >> union all
> >> select e.tail, ee.head from Edges e, TransClosedEdges ee
> >> where e.head = ee.tail
> >>)
> >>select distinct * from TransClosedEdges
> >>
> >>except that this query might never terminate.
> >
> >
> > Oops, it's actually quite obvious
> >
> > with TransClosedEdges (tail, head) as
> > ( select tail, head from Edges
> > where tail <> head --*******
> > union all
> > select e.tail, ee.head from Edges e, TransClosedEdges ee
> > where e.head = ee.tail
> > and e.tail <> ee.head --*******
> > )
> > select distinct * from TransClosedEdges
> >
> > Graeme handles more general case, hence the complication.
> >
> There will be a new developerWorks article on mapping CONnECT BY to DB2
> tomorrow (if all goes well).
See your article. Unfortunately, understanding code in C is beyond my capabilities. What is "binary-encoded path"? Suppose we have
Name Sal
------------ ---
KING 100 --> SMITH 50
![]() |
![]() |