// File: GraphTools_BFSIterator.gxx // Created: Mon Oct 12 16:34:41 1992 // Author: Denis PASCAL // #include #include #include //======================================================================= //function : GraphTools_BFSIterator //purpose : //======================================================================= GraphTools_BFSIterator::GraphTools_BFSIterator () {} //======================================================================= //function : Perform //purpose : //======================================================================= void GraphTools_BFSIterator::Perform (const Graph& G, const Vertex& V) { Standard_Integer index; myVisited.Clear(); TColStd_QueueOfInteger myReady; index = myVisited.Add(V); myReady.Push(index); while (!myReady.IsEmpty()) { Vertex w1 = myVisited (myReady.Front()); myReady.Pop(); for (VIterator it(G,w1); it.More(); it.Next()) { Vertex w2 = it.Value(); if (!myVisited.Contains(w2)) { index = myVisited.Add(w2); myReady.Push(index); } } } myCurrentIndex = 1; } //======================================================================= //function : More //purpose : //======================================================================= Standard_Boolean GraphTools_BFSIterator::More () const { return myCurrentIndex <= myVisited.Extent(); } //======================================================================= //function : Next //purpose : //======================================================================= void GraphTools_BFSIterator::Next () { myCurrentIndex++; } //======================================================================= //function : Value //purpose : //======================================================================= const Vertex& GraphTools_BFSIterator::Value () const { return myVisited(myCurrentIndex); }