[Lemon-commits] [lemon_svn] deba: r1227 - in hugo/trunk/src: hugo test
Lemon SVN
svn at lemon.cs.elte.hu
Mon Nov 6 20:44:00 CET 2006
Author: deba
Date: Tue Sep 28 18:40:55 2004
New Revision: 1227
Modified:
hugo/trunk/src/hugo/list_graph.h
hugo/trunk/src/hugo/smart_graph.h
hugo/trunk/src/test/graph_test.h
Log:
Fix InEdgeIt and OutEdgeIt in the symmetric graphs.
Modified: hugo/trunk/src/hugo/list_graph.h
==============================================================================
--- hugo/trunk/src/hugo/list_graph.h (original)
+++ hugo/trunk/src/hugo/list_graph.h Tue Sep 28 18:40:55 2004
@@ -102,6 +102,7 @@
first_free_node(_g.first_free_node), edges(_g.edges),
first_free_edge(_g.first_free_edge) {}
+ /// \bug In the vector can be hole if a node is erased from the graph.
///Number of nodes.
int nodeNum() const { return nodes.size(); }
///Number of edges.
@@ -579,7 +580,7 @@
public:
OutEdgeIt() {}
OutEdgeIt(const SymListGraph& g, Edge e) {
- if (e.id & 1 == 0) {
+ if ((e.id & 1) == 0) {
out = Parent::OutEdgeIt(g, SymEdge(e));
in = Parent::InEdgeIt(g, g.tail(e));
} else {
@@ -616,7 +617,7 @@
public:
InEdgeIt() {}
InEdgeIt(const SymListGraph& g, Edge e) {
- if (e.id & 1 == 0) {
+ if ((e.id & 1) == 0) {
out = Parent::OutEdgeIt(g, SymEdge(e));
in = Parent::InEdgeIt(g, g.tail(e));
} else {
@@ -732,12 +733,12 @@
Node tail(Edge e) const {
- return e.id & 1 == 0 ?
+ return (e.id & 1) == 0 ?
Parent::tail(SymEdge(e)) : Parent::head(SymEdge(e));
}
Node head(Edge e) const {
- return e.id & 1 == 0 ?
+ return (e.id & 1) == 0 ?
Parent::head(SymEdge(e)) : Parent::tail(SymEdge(e));
}
@@ -822,14 +823,14 @@
return INVALID;
}
- /// Finds an symmetric edge between two nodes.
+// /// Finds an symmetric edge between two nodes.
- /// Finds an symmetric edge from node \c u to node \c v.
- ///
- /// If \c prev is \ref INVALID (this is the default value), then
- /// It finds the first edge from \c u to \c v. Otherwise it looks for
- /// the next edge from \c u to \c v after \c prev.
- /// \return The found edge or INVALID if there is no such an edge.
+// /// Finds an symmetric edge from node \c u to node \c v.
+// ///
+// /// If \c prev is \ref INVALID (this is the default value), then
+// /// It finds the first edge from \c u to \c v. Otherwise it looks for
+// /// the next edge from \c u to \c v after \c prev.
+// /// \return The found edge or INVALID if there is no such an edge.
// SymEdge findEdge(Node u, Node v, SymEdge prev = INVALID)
// {
@@ -873,7 +874,7 @@
}
static Edge backward(SymEdge e) {
- return Edge((id(e) << 1) & 1);
+ return Edge((id(e) << 1) | 1);
}
};
Modified: hugo/trunk/src/hugo/smart_graph.h
==============================================================================
--- hugo/trunk/src/hugo/smart_graph.h (original)
+++ hugo/trunk/src/hugo/smart_graph.h Tue Sep 28 18:40:55 2004
@@ -394,7 +394,7 @@
public:
OutEdgeIt() {}
OutEdgeIt(const SymSmartGraph& g, Edge e) {
- if (e.id & 1 == 0) {
+ if ((e.id & 1) == 0) {
out = Parent::OutEdgeIt(g, SymEdge(e));
in = Parent::InEdgeIt(g, g.tail(e));
} else {
@@ -431,7 +431,7 @@
public:
InEdgeIt() {}
InEdgeIt(const SymSmartGraph& g, Edge e) {
- if (e.id & 1 == 0) {
+ if ((e.id & 1) == 0) {
out = Parent::OutEdgeIt(g, SymEdge(e));
in = Parent::InEdgeIt(g, g.tail(e));
} else {
@@ -540,12 +540,12 @@
Node tail(Edge e) const {
- return e.id & 1 == 0 ?
+ return (e.id & 1) == 0 ?
Parent::tail(SymEdge(e)) : Parent::head(SymEdge(e));
}
Node head(Edge e) const {
- return e.id & 1 == 0 ?
+ return (e.id & 1) == 0 ?
Parent::head(SymEdge(e)) : Parent::tail(SymEdge(e));
}
@@ -630,14 +630,14 @@
return INVALID;
}
- /// Finds an symmetric edge between two nodes.
+// /// Finds an symmetric edge between two nodes.
- /// Finds an symmetric edge from node \c u to node \c v.
- ///
- /// If \c prev is \ref INVALID (this is the default value), then
- /// It finds the first edge from \c u to \c v. Otherwise it looks for
- /// the next edge from \c u to \c v after \c prev.
- /// \return The found edge or INVALID if there is no such an edge.
+// /// Finds an symmetric edge from node \c u to node \c v.
+// ///
+// /// If \c prev is \ref INVALID (this is the default value), then
+// /// It finds the first edge from \c u to \c v. Otherwise it looks for
+// /// the next edge from \c u to \c v after \c prev.
+// /// \return The found edge or INVALID if there is no such an edge.
// SymEdge findEdge(Node u, Node v, SymEdge prev = INVALID)
// {
@@ -667,7 +667,7 @@
}
static Edge backward(SymEdge e) {
- return Edge((id(e) << 1) & 1);
+ return Edge((id(e) << 1) | 1);
}
};
Modified: hugo/trunk/src/test/graph_test.h
==============================================================================
--- hugo/trunk/src/test/graph_test.h (original)
+++ hugo/trunk/src/test/graph_test.h Tue Sep 28 18:40:55 2004
@@ -298,6 +298,7 @@
typename Graph::OutEdgeIt e(G,n);
for(int i=0;i<nn;i++) {
check(e!=INVALID,"Wrong OutEdge list linking.");
+ check(n==G.tail(e), "Wrong OutEdge list linking.");
++e;
}
check(e==INVALID,"Wrong OutEdge list linking.");
@@ -310,6 +311,7 @@
typename Graph::InEdgeIt e(G,n);
for(int i=0;i<nn;i++) {
check(e!=INVALID,"Wrong InEdge list linking.");
+ check(n==G.head(e), "Wrong InEdge list linking.");
++e;
}
check(e==INVALID,"Wrong InEdge list linking.");
More information about the Lemon-commits
mailing list