Untitled

 avatar
unknown
plain_text
3 years ago
736 B
6
Indexable
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 

                    }
                }       
Editor is loading...