Closed mpickering closed 8 years ago
What is DTMC
? It makes it difficult for me to tell what you're doing here.
Note that ufold
removes the node each time it recurses, whereas I'm guessing that your first function considers the entire graph.
Why does ufold
remove the node when it recurses? I think that is my problem.
type DTMC = Gr [String] Rational
Because it's a fold: just like foldr
removes that list element as it recurses.
What are you trying to find? The last node that has an out-going weight of 1
?
If so, I would use a variant of your first one:
consistency :: DTMC -> Maybe Node
consistency dtmc = listToMaybe . filter ((==1) . sum . map edgeLabel . out dtmc)
$ nodes dtmc
Note that performance-wise, if all you want is the Node
then this would be as performant as a Context
-based approach, possibly even a tad better (no need to get the in-coming edges, delete the node from the graph, etc.).
Is this issue still relevant?
No.
I expected the following two functions to be equivalent but ufold gives strange answers. Specifically, the context was missing self-loops and incoming edges, am I misusing ufold here?