Untitled

mail@pastecode.io avatar
unknown
plain_text
2 years ago
736 B
2
Indexable
Never
public void DepthFirstTraverse(T startID, ref List<T> visited)
                {
                    LinkedList<T> adj;
                    Stack<T> toVisit = new Stack<T>();

                    GraphNode<T> current = new GraphNode<T>(startID);

                    toVisit.Push(startID);

                    while (toVisit.Count != 0)
                    {
                    startID = toVisit.Dequeue();
                    current = GetNodeByID(startID);
                    visited.Add(current.ID);
                        //to be completed. Hint: get current node to the list of visited nodes and add its adjacent nodes (only those not already visited) to toVist 

                    }
                }