shape_doc 0.1
|
Iterator for DFS traversal. More...
#include <graph.hpp>
Iterator for DFS traversal.
GraphDfsIter | ( | const Graph< T > | s | ) | [inline] |
void first | ( | ) | [inline] |
Definition at line 210 of file graph.hpp.
References gNode< T >::status().
{ current = g->head; next_start=current->vlist; gNode<T>* t=current; while(t!=NULL)// Mark all as not visited { t->status(-1); t=t->vlist; } current->status(0); }
bool isLast | ( | ) | [inline] |
void next | ( | ) | [inline] |
Definition at line 249 of file graph.hpp.
{ if ( q.empty() ) { while( next_start!=NULL) { if ( next_start->status()==-1) { next_start->status(0); q.push(next_start); next_start=next_start->vlist; break; } next_start=next_start->vlist; } if (next_start==NULL)// Finished { current= NULL; //isDone return; } } // q not empty current= q.top(); q.pop(); gNode<T>* t=current; while(t->next!=NULL) { if ( t->next->status() == -1 ) { t->next->status(0); // mark as visited q.push(t->next->start); } t=t->next; } return; }