Let's say I have a cyclic control flow graph
A -> B -> C -> D -> G
^ |
| v
F <------ E
Each node is associated with a cost.
I additionally have a state variable that is modified each time I enter node D. The probability of D -> E
and D -> G
is determined by this state variable.
What I want is to enumerate all possible paths (at a certain state P( D -> G) = 1
), and find the probability and cost for each path. The first step, I think is transforming this control flow graph with state variable to a directed acyclic graph by unrolling it. Is there a straightforward algorithm for this? Any libraries (like networkx) that can help?