src/work/marci/bfs_dfs.h
changeset 774 4297098d9677
parent 671 708df4dc6ab6
child 777 a82713ed19f3
     1.1 --- a/src/work/marci/bfs_dfs.h	Wed Aug 25 18:55:57 2004 +0000
     1.2 +++ b/src/work/marci/bfs_dfs.h	Mon Aug 30 12:01:47 2004 +0000
     1.3 @@ -60,8 +60,8 @@
     1.4        if (bfs_queue.empty()) {
     1.5  	bfs_queue.push(s);
     1.6  	graph->first(actual_edge, s);
     1.7 -	if (graph->valid(actual_edge)) { 
     1.8 -	  Node w=graph->bNode(actual_edge);
     1.9 +	if (actual_edge!=INVALID) { 
    1.10 +	  Node w=graph->head(actual_edge);
    1.11  	  if (!reached[w]) {
    1.12  	    bfs_queue.push(w);
    1.13  	    reached.set(w, true);
    1.14 @@ -78,10 +78,10 @@
    1.15      /// its \c operator++() iterates on the edges in a bfs order.
    1.16      BfsIterator<Graph, /*OutEdgeIt,*/ ReachedMap>& 
    1.17      operator++() { 
    1.18 -      if (graph->valid(actual_edge)) { 
    1.19 -	graph->next(actual_edge);
    1.20 -	if (graph->valid(actual_edge)) {
    1.21 -	  Node w=graph->bNode(actual_edge);
    1.22 +      if (actual_edge!=INVALID) { 
    1.23 +	++actual_edge;
    1.24 +	if (actual_edge!=INVALID) {
    1.25 +	  Node w=graph->head(actual_edge);
    1.26  	  if (!reached[w]) {
    1.27  	    bfs_queue.push(w);
    1.28  	    reached.set(w, true);
    1.29 @@ -94,8 +94,8 @@
    1.30  	bfs_queue.pop(); 
    1.31  	if (!bfs_queue.empty()) {
    1.32  	  graph->first(actual_edge, bfs_queue.front());
    1.33 -	  if (graph->valid(actual_edge)) {
    1.34 -	    Node w=graph->bNode(actual_edge);
    1.35 +	  if (actual_edge!=INVALID) {
    1.36 +	    Node w=graph->head(actual_edge);
    1.37  	    if (!reached[w]) {
    1.38  	      bfs_queue.push(w);
    1.39  	      reached.set(w, true);
    1.40 @@ -117,7 +117,7 @@
    1.41      /// Returns if b-node has been reached just now.
    1.42      bool isBNodeNewlyReached() const { return b_node_newly_reached; }
    1.43      /// Returns if a-node is examined.
    1.44 -    bool isANodeExamined() const { return !(graph->valid(actual_edge)); }
    1.45 +    bool isANodeExamined() const { return actual_edge==INVALID; }
    1.46      /// Returns a-node of the actual edge, so does if the edge is invalid.
    1.47      Node aNode() const { return bfs_queue.front(); }
    1.48      /// \pre The actual edge have to be valid.
    1.49 @@ -237,8 +237,8 @@
    1.50      operator++() { 
    1.51        actual_edge=dfs_stack.top();
    1.52        //actual_node=G.aNode(actual_edge);
    1.53 -      if (graph->valid(actual_edge)/*.valid()*/) { 
    1.54 -	Node w=graph->bNode(actual_edge);
    1.55 +      if (actual_edge!=INVALID/*.valid()*/) { 
    1.56 +	Node w=graph->head(actual_edge);
    1.57  	actual_node=w;
    1.58  	if (!reached[w]) {
    1.59  	  OutEdgeIt e;
    1.60 @@ -247,8 +247,8 @@
    1.61  	  reached.set(w, true);
    1.62  	  b_node_newly_reached=true;
    1.63  	} else {
    1.64 -	  actual_node=graph->aNode(actual_edge);
    1.65 -	  graph->next(dfs_stack.top());
    1.66 +	  actual_node=graph->tail(actual_edge);
    1.67 +	  ++dfs_stack.top();
    1.68  	  b_node_newly_reached=false;
    1.69  	}
    1.70        } else {
    1.71 @@ -266,7 +266,7 @@
    1.72      /// Returns if b-node has been reached just now.
    1.73      bool isBNodeNewlyReached() const { return b_node_newly_reached; }
    1.74      /// Returns if a-node is examined.
    1.75 -    bool isANodeExamined() const { return !(graph->valid(actual_edge)); }
    1.76 +    bool isANodeExamined() const { return actual_edge==INVALID; }
    1.77      /// Returns a-node of the actual edge, so does if the edge is invalid.
    1.78      Node aNode() const { return actual_node; /*FIXME*/}
    1.79      /// Returns b-node of the actual edge.