There was a thread last November entitled "Transitive closure of a directed graph" on the [HACKERS] list. There may be some information of use there.
pgsql-general by date:
Соглашаюсь с условиями обработки персональных данных