haskell / fgl

A Functional Graph Library for Haskell

Home Page:http://hackage.haskell.org/package/fgl

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

transitive closure function "trc" is also reflexive

mrd opened this issue · comments

The function "trc" in module TransClos computes the transitive, reflexive closure of a graph, rather than merely the transitive closure. The difference is acute when dealing with directed acyclic graphs: the transitive closure of a DAG should also be a DAG, but the transitive, reflexive closure will not be.

The reason this happens is because "trc" invokes a function that invokes "reachable", and the first element of the list returned by "reachable" is the node itself.

The comment documentation says that "trc" only computes the "transitive closure". I am happy to submit a pull request with my versions of these functions that separate transitive closure from reflexive closure. But I would like to know the naming convention desired here. It occurs to me that the name "trc" could stand for either "TRansitive closure" or "Transitive Reflexive Closure". The test cases in the library seem to assume that "trc" computes the transitive, reflexive closure. So perhaps it is best to leave "trc" as "Transitive Reflexive Closure", update the documentation, and create a new function for "Transitive Closure" (tentatively named "tc").

What do you think?

Please do submit a pull request; apart from cosmetic clean-ups I haven't really touched this module/function.