Fix InEdgeIt and OutEdgeIt in the symmetric graphs.
authordeba
Tue, 28 Sep 2004 16:40:55 +0000
changeset 916c0734a8c282c
parent 915 751ed145bdae
child 917 ffb8f0cbcb57
Fix InEdgeIt and OutEdgeIt in the symmetric graphs.
src/hugo/list_graph.h
src/hugo/smart_graph.h
src/test/graph_test.h
     1.1 --- a/src/hugo/list_graph.h	Tue Sep 28 13:45:39 2004 +0000
     1.2 +++ b/src/hugo/list_graph.h	Tue Sep 28 16:40:55 2004 +0000
     1.3 @@ -102,6 +102,7 @@
     1.4  	first_free_node(_g.first_free_node), edges(_g.edges),
     1.5  	first_free_edge(_g.first_free_edge) {}
     1.6      
     1.7 +    /// \bug In the vector can be hole if a node is erased from the graph.
     1.8      ///Number of nodes.
     1.9      int nodeNum() const { return nodes.size(); }
    1.10      ///Number of edges.
    1.11 @@ -579,7 +580,7 @@
    1.12      public: 
    1.13        OutEdgeIt() {}
    1.14        OutEdgeIt(const SymListGraph& g, Edge e) { 
    1.15 -	if (e.id & 1 == 0) {	
    1.16 +	if ((e.id & 1) == 0) {	
    1.17  	  out = Parent::OutEdgeIt(g, SymEdge(e));
    1.18  	  in = Parent::InEdgeIt(g, g.tail(e));
    1.19  	} else {
    1.20 @@ -616,7 +617,7 @@
    1.21      public: 
    1.22        InEdgeIt() {}
    1.23        InEdgeIt(const SymListGraph& g, Edge e) { 
    1.24 -	if (e.id & 1 == 0) {	
    1.25 +	if ((e.id & 1) == 0) {	
    1.26  	  out = Parent::OutEdgeIt(g, SymEdge(e));
    1.27  	  in = Parent::InEdgeIt(g, g.tail(e));
    1.28  	} else {
    1.29 @@ -732,12 +733,12 @@
    1.30  
    1.31  
    1.32      Node tail(Edge e) const { 
    1.33 -      return e.id & 1 == 0 ? 
    1.34 +      return (e.id & 1) == 0 ? 
    1.35  	Parent::tail(SymEdge(e)) : Parent::head(SymEdge(e)); 
    1.36      }
    1.37  
    1.38      Node head(Edge e) const { 
    1.39 -      return e.id & 1 == 0 ? 
    1.40 +      return (e.id & 1) == 0 ? 
    1.41  	Parent::head(SymEdge(e)) : Parent::tail(SymEdge(e)); 
    1.42      }
    1.43  
    1.44 @@ -822,14 +823,14 @@
    1.45        return INVALID;
    1.46      }
    1.47  
    1.48 -    /// Finds an symmetric edge between two nodes.
    1.49 +//     /// Finds an symmetric edge between two nodes.
    1.50  
    1.51 -    /// Finds an symmetric edge from node \c u to node \c v.
    1.52 -    ///
    1.53 -    /// If \c prev is \ref INVALID (this is the default value), then
    1.54 -    /// It finds the first edge from \c u to \c v. Otherwise it looks for
    1.55 -    /// the next edge from \c u to \c v after \c prev.
    1.56 -    /// \return The found edge or INVALID if there is no such an edge.
    1.57 +//     /// Finds an symmetric edge from node \c u to node \c v.
    1.58 +//     ///
    1.59 +//     /// If \c prev is \ref INVALID (this is the default value), then
    1.60 +//     /// It finds the first edge from \c u to \c v. Otherwise it looks for
    1.61 +//     /// the next edge from \c u to \c v after \c prev.
    1.62 +//     /// \return The found edge or INVALID if there is no such an edge.
    1.63  
    1.64  //     SymEdge findEdge(Node u, Node v, SymEdge prev = INVALID) 
    1.65  //     {     
    1.66 @@ -873,7 +874,7 @@
    1.67      }
    1.68  
    1.69      static Edge backward(SymEdge e) {
    1.70 -      return Edge((id(e) << 1) & 1);
    1.71 +      return Edge((id(e) << 1) | 1);
    1.72      }
    1.73  
    1.74    };
     2.1 --- a/src/hugo/smart_graph.h	Tue Sep 28 13:45:39 2004 +0000
     2.2 +++ b/src/hugo/smart_graph.h	Tue Sep 28 16:40:55 2004 +0000
     2.3 @@ -394,7 +394,7 @@
     2.4      public: 
     2.5        OutEdgeIt() {}
     2.6        OutEdgeIt(const SymSmartGraph& g, Edge e) { 
     2.7 -	if (e.id & 1 == 0) {	
     2.8 +	if ((e.id & 1) == 0) {	
     2.9  	  out = Parent::OutEdgeIt(g, SymEdge(e));
    2.10  	  in = Parent::InEdgeIt(g, g.tail(e));
    2.11  	} else {
    2.12 @@ -431,7 +431,7 @@
    2.13      public: 
    2.14        InEdgeIt() {}
    2.15        InEdgeIt(const SymSmartGraph& g, Edge e) { 
    2.16 -	if (e.id & 1 == 0) {	
    2.17 +	if ((e.id & 1) == 0) {	
    2.18  	  out = Parent::OutEdgeIt(g, SymEdge(e));
    2.19  	  in = Parent::InEdgeIt(g, g.tail(e));
    2.20  	} else {
    2.21 @@ -540,12 +540,12 @@
    2.22  
    2.23  
    2.24      Node tail(Edge e) const { 
    2.25 -      return e.id & 1 == 0 ? 
    2.26 +      return (e.id & 1) == 0 ? 
    2.27  	Parent::tail(SymEdge(e)) : Parent::head(SymEdge(e)); 
    2.28      }
    2.29  
    2.30      Node head(Edge e) const { 
    2.31 -      return e.id & 1 == 0 ? 
    2.32 +      return (e.id & 1) == 0 ? 
    2.33  	Parent::head(SymEdge(e)) : Parent::tail(SymEdge(e)); 
    2.34      }
    2.35  
    2.36 @@ -630,14 +630,14 @@
    2.37        return INVALID;
    2.38      }
    2.39  
    2.40 -    /// Finds an symmetric edge between two nodes.
    2.41 +//     /// Finds an symmetric edge between two nodes.
    2.42  
    2.43 -    /// Finds an symmetric edge from node \c u to node \c v.
    2.44 -    ///
    2.45 -    /// If \c prev is \ref INVALID (this is the default value), then
    2.46 -    /// It finds the first edge from \c u to \c v. Otherwise it looks for
    2.47 -    /// the next edge from \c u to \c v after \c prev.
    2.48 -    /// \return The found edge or INVALID if there is no such an edge.
    2.49 +//     /// Finds an symmetric edge from node \c u to node \c v.
    2.50 +//     ///
    2.51 +//     /// If \c prev is \ref INVALID (this is the default value), then
    2.52 +//     /// It finds the first edge from \c u to \c v. Otherwise it looks for
    2.53 +//     /// the next edge from \c u to \c v after \c prev.
    2.54 +//     /// \return The found edge or INVALID if there is no such an edge.
    2.55  
    2.56  //     SymEdge findEdge(Node u, Node v, SymEdge prev = INVALID) 
    2.57  //     {     
    2.58 @@ -667,7 +667,7 @@
    2.59      }
    2.60  
    2.61      static Edge backward(SymEdge e) {
    2.62 -      return Edge((id(e) << 1) & 1);
    2.63 +      return Edge((id(e) << 1) | 1);
    2.64      }
    2.65  
    2.66    };
     3.1 --- a/src/test/graph_test.h	Tue Sep 28 13:45:39 2004 +0000
     3.2 +++ b/src/test/graph_test.h	Tue Sep 28 16:40:55 2004 +0000
     3.3 @@ -298,6 +298,7 @@
     3.4        typename Graph::OutEdgeIt e(G,n);
     3.5        for(int i=0;i<nn;i++) {
     3.6  	check(e!=INVALID,"Wrong OutEdge list linking.");
     3.7 +	check(n==G.tail(e), "Wrong OutEdge list linking.");
     3.8  	++e;
     3.9        }
    3.10        check(e==INVALID,"Wrong OutEdge list linking.");
    3.11 @@ -310,6 +311,7 @@
    3.12        typename Graph::InEdgeIt e(G,n);
    3.13        for(int i=0;i<nn;i++) {
    3.14  	check(e!=INVALID,"Wrong InEdge list linking.");
    3.15 +	check(n==G.head(e), "Wrong InEdge list linking.");
    3.16  	++e;
    3.17        }
    3.18        check(e==INVALID,"Wrong InEdge list linking.");