Example #1
0
        private void DFS(int v, int dest, Stack <int> stack, int cost)
        {
            stack.Push(v);
            visited[v] = true;

            if (v == dest)
            {
                visited[dest] = false;//let other paths arrive at destination
                paths.Add(cost, stack.ToList().Reverse <int>());
            }
            else
            {
                foreach (int w in graph.GetAdjacents(v))
                {
                    if (!visited[w])
                    {
                        DFS(w, dest, stack, cost + graph.GetCost(v, w));
                    }
                }
            }

            stack.Pop();
        }