Graph.cc
/**
 * The following represents the colors:
 *
 *         discovered  explored
 * White    false       false
 * Gray     true        false
 * Black    true        true
 */
The following represents the colors:
discovered  explored
White    false       false
Gray     true        false
Black    true        true
The following represents the colors : discovered explored White false false Gray true false Black true true
void Graph::BFS( Vertex *start ) {
    VertexQueue q;
    start->discovered = true;
    q.enqueue( start );
    while ( q.not_empty() ) {
        Vertex *u = q.dequeue();
        u->pointcut._enter_();
        u->visit();
        for ( EdgeList *edges = u->edges ; edges != NULL ; edges = edges->next ) {
            Edge *edge = edges->edge;
            edge->pointcut._enter_();
            edge->visit();
            Vertex *v = edge->vertex;
            if ( v->discovered ) {
                edge->pointcut._leave_();
                continue;
            }
            v->discovered = true;
            v->distance = u->distance + 1;
            v->parent = u;
            q.enqueue( v );
            edge->pointcut._leave_();
        }
        u->explored = true;
        u->pointcut._leave_();
    }
}
void Graph :: BFS ( Vertex * start ) { VertexQueue q ; start -> discovered = true ; q . enqueue ( start ) ; while ( q . not_empty ( ) ) { Vertex * u = q . dequeue ( ) ; u -> pointcut . _enter_ ( ) ; u -> visit ( ) ; for ( EdgeList * edges = u -> edges ; edges != NULL ; edges = edges -> next ) { Edge * edge = edges -> edge ; edge -> pointcut . _enter_ ( ) ; edge -> visit ( ) ; Vertex * v = edge -> vertex ; if ( v -> discovered ) { edge -> pointcut . _leave_ ( ) ; continue ; } v -> discovered = true ; v -> distance = u -> distance + 1 ; v -> parent = u ; q . enqueue ( v ) ; edge -> pointcut . _leave_ ( ) ; } u -> explored = true ; u -> pointcut . _leave_ ( ) ; } }
The following represents the colors:
         discovered  explored
 White    false       false
 Gray     true        false
 Black    true        true
The following represents the colors : discovered explored White false false Gray true false Black true true