I have a directed acyclic graph where each node is represent by a state
public class State{
List<State> ForwardStates;
List<State> backStates;
string stateName;
}
where ForwardStates
is a list of states via forward links from the current state.
and backStates
is a list of states via backward links from the current state.
I have two special state
State initialState (name=initial)
State finalState (name=final)
I wish to find all paths the start from initial state to final state, and populated in
List<List<string>> paths
For example given the graph like the following
Where backward links are represented by brown dotted arrow and forward links is represented by black concrete arrow, the possible paths are {{initial, b, a, final},{initial, c, final},{initial, b, initial,final}}
The rule is that from initial state, it must go through 1 or more backward links, before go through forward link, and once it switch to forward link, it will keep to forward links (i.e., it can't use the backward links anymore).
This question is an extension of this question(Collecting all paths of DAG).