Unable to run regular graph functions on acyclic graphs
DavidDTA opened this issue · comments
Since AcyclicGraph
is an opaque type it can not be passed into the normal graph functions (such as nodeIds
). This means that if I want to run both functions which require an acyclic graph and those that do not I need to keep around two references to the same graph (one of type Graph
, and the other of type AcyclicGraph
).
There are two solutions to this:
- Create a method
forgetAcyclicness : AcyclicGraph n e -> Graph n e
which can be used to obtain aGraph
reference from anAcyclicGraph
. This is the easier approach from the current state of the library. - Create a nonce type
Acyclic
and add a phantom type variable toGraph
. The graph creation methods would returnGraph n e ()
and most of the existing methods could then take aGraph n e a
, but the acyclic ones would only acceptGraph n e Acyclic
. This is I think the conceptually cleaner approach.
Thanks for your input! I'd happily accept a PR implementing 1.
I'd be happy to make one! Do you have input regarding the name of that method? My instinct would probably be acyclicGraphToGraph
.
Actually, I came to like forgetAcyclic
or getAcyclicGraph
. Anyway, choose one that suits you.