> A --> B --> C
>       \
>        \--> D --> E

You've drawn a tree, but your comments indicate that you
want something more general.

If you can restrict yourself to trees, you can probably
use nested sets (invented by Joe Celko). These are fairly
simple to manipulate. A Google search will turn up
articles explaining the method.

If you must have a more general graph, you'll probably
have to store all the paths you're interested in, e.g.,

   A/B
   A/B/C
   A/B/D
   A/B/D/E

If you're interested in paths that don't start at the
root, you'll need also

   B/C
   B/D
   B/D/E
   D/E

If you add an arc directly from A to E, you'll need A/E.

You could then get all the paths from A to E by searching
for Path LIKE 'A%E'. In this case, you'll probably want
to get all the paths you're interested in and then
analyze and manipulate them in your host language.

Things would be much simpler if you could limit yourself
to trees modeled as nested sets.

Regards

Reply via email to