countUndirEdges bugs fixed
authorklao
Wed, 05 Jan 2005 16:59:50 +0000
changeset 10546a62b1b4cf23
parent 1053 90f8696360b2
child 1055 f901ff02b2d7
countUndirEdges bugs fixed
src/lemon/undir_graph_extender.h
src/test/undir_graph_test.cc
     1.1 --- a/src/lemon/undir_graph_extender.h	Wed Jan 05 14:34:00 2005 +0000
     1.2 +++ b/src/lemon/undir_graph_extender.h	Wed Jan 05 16:59:50 2005 +0000
     1.3 @@ -237,6 +237,14 @@
     1.4        return Parent::maxId(typename Parent::Edge());
     1.5      }
     1.6  
     1.7 +
     1.8 +    int edgeNum() const {
     1.9 +      return 2 * Parent::edgeNum();
    1.10 +    }
    1.11 +    int undirEdgeNum() const {
    1.12 +      return Parent::edgeNum();
    1.13 +    }
    1.14 +
    1.15    };
    1.16  
    1.17  }
     2.1 --- a/src/test/undir_graph_test.cc	Wed Jan 05 14:34:00 2005 +0000
     2.2 +++ b/src/test/undir_graph_test.cc	Wed Jan 05 16:59:50 2005 +0000
     2.3 @@ -43,20 +43,19 @@
     2.4    checkConcept<UndirGraph, UndirGraph>();
     2.5  }
     2.6  
     2.7 -typedef UndirListGraph Graph;
     2.8 -typedef Graph::Node Node;
     2.9 -typedef Graph::UndirEdge UEdge;
    2.10 -typedef Graph::Edge Edge;
    2.11 -typedef Graph::NodeIt NodeIt;
    2.12 -typedef Graph::UndirEdgeIt UEdgeIt;
    2.13 -typedef Graph::EdgeIt EdgeIt;
    2.14 -
    2.15 +template <typename Graph>
    2.16  void check_item_counts(Graph &g, int n, int e) {
    2.17    check(countNodes(g)==n, "Wrong node number.");
    2.18    check(countEdges(g)==2*e, "Wrong edge number.");
    2.19  }
    2.20  
    2.21 +template <typename Graph>
    2.22  void print_items(Graph &g) {
    2.23 +
    2.24 +  typedef typename Graph::NodeIt NodeIt;
    2.25 +  typedef typename Graph::UndirEdgeIt UEdgeIt;
    2.26 +  typedef typename Graph::EdgeIt EdgeIt;
    2.27 +
    2.28    cout << "Nodes" << endl;
    2.29    int i=0;
    2.30    for(NodeIt it(g); it!=INVALID; ++it, ++i) {
    2.31 @@ -81,9 +80,15 @@
    2.32  
    2.33  }
    2.34  
    2.35 -int main() {
    2.36 -  check_concepts();
    2.37 +template <typename Graph>
    2.38 +void check_graph() {
    2.39  
    2.40 +  typedef typename Graph::Node Node;
    2.41 +  typedef typename Graph::UndirEdge UEdge;
    2.42 +  typedef typename Graph::Edge Edge;
    2.43 +  typedef typename Graph::NodeIt NodeIt;
    2.44 +  typedef typename Graph::UndirEdgeIt UEdgeIt;
    2.45 +  typedef typename Graph::EdgeIt EdgeIt;
    2.46  
    2.47    Graph g;
    2.48  
    2.49 @@ -102,5 +107,14 @@
    2.50  
    2.51    check_item_counts(g,3,2);
    2.52  
    2.53 +
    2.54 +}
    2.55 +
    2.56 +int main() {
    2.57 +  check_concepts();
    2.58 +
    2.59 +  check_graph<UndirListGraph>();
    2.60 +  check_graph<UndirSmartGraph>();
    2.61 +
    2.62    return 0;
    2.63  }