I have a directed acyclic graph where each node is represent by a state
public class State{
List<State> ForwardStates;
string stateName;
}
where ForwardStates
is a list of next states 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
paths
should contain the value
{{"initial","a","final"},{"initial","b","final"}}
How should I achieve this easily in C# without recursion (as the graph might be big)?