test/euler_test.cc
changeset 895 dca9eed2c375
parent 592 2ebfdb89ec66
child 998 7fdaa05a69a1
equal deleted inserted replaced
2:8b84a500e763 3:533853a53f60
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
     2  *
     2  *
     3  * This file is a part of LEMON, a generic C++ optimization library.
     3  * This file is a part of LEMON, a generic C++ optimization library.
     4  *
     4  *
     5  * Copyright (C) 2003-2009
     5  * Copyright (C) 2003-2010
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     6  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     7  * (Egervary Research Group on Combinatorial Optimization, EGRES).
     8  *
     8  *
     9  * Permission to use, modify and distribute this software is granted
     9  * Permission to use, modify and distribute this software is granted
    10  * provided that this copyright notice appears in all copies. For
    10  * provided that this copyright notice appears in all copies. For
    83 
    83 
    84 int main()
    84 int main()
    85 {
    85 {
    86   typedef ListDigraph Digraph;
    86   typedef ListDigraph Digraph;
    87   typedef Undirector<Digraph> Graph;
    87   typedef Undirector<Digraph> Graph;
    88   
    88 
    89   {
    89   {
    90     Digraph d;
    90     Digraph d;
    91     Graph g(d);
    91     Graph g(d);
    92     
    92 
    93     checkDiEulerIt(d);
    93     checkDiEulerIt(d);
    94     checkDiEulerIt(g);
    94     checkDiEulerIt(g);
    95     checkEulerIt(g);
    95     checkEulerIt(g);
    96 
    96 
    97     check(eulerian(d), "This graph is Eulerian");
    97     check(eulerian(d), "This graph is Eulerian");
   126     Digraph d;
   126     Digraph d;
   127     Graph g(d);
   127     Graph g(d);
   128     Digraph::Node n1 = d.addNode();
   128     Digraph::Node n1 = d.addNode();
   129     Digraph::Node n2 = d.addNode();
   129     Digraph::Node n2 = d.addNode();
   130     Digraph::Node n3 = d.addNode();
   130     Digraph::Node n3 = d.addNode();
   131     
   131 
   132     d.addArc(n1, n2);
   132     d.addArc(n1, n2);
   133     d.addArc(n2, n1);
   133     d.addArc(n2, n1);
   134     d.addArc(n2, n3);
   134     d.addArc(n2, n3);
   135     d.addArc(n3, n2);
   135     d.addArc(n3, n2);
   136 
   136 
   151     Digraph::Node n2 = d.addNode();
   151     Digraph::Node n2 = d.addNode();
   152     Digraph::Node n3 = d.addNode();
   152     Digraph::Node n3 = d.addNode();
   153     Digraph::Node n4 = d.addNode();
   153     Digraph::Node n4 = d.addNode();
   154     Digraph::Node n5 = d.addNode();
   154     Digraph::Node n5 = d.addNode();
   155     Digraph::Node n6 = d.addNode();
   155     Digraph::Node n6 = d.addNode();
   156     
   156 
   157     d.addArc(n1, n2);
   157     d.addArc(n1, n2);
   158     d.addArc(n2, n4);
   158     d.addArc(n2, n4);
   159     d.addArc(n1, n3);
   159     d.addArc(n1, n3);
   160     d.addArc(n3, n4);
   160     d.addArc(n3, n4);
   161     d.addArc(n4, n1);
   161     d.addArc(n4, n1);
   187     Digraph::Node n1 = d.addNode();
   187     Digraph::Node n1 = d.addNode();
   188     Digraph::Node n2 = d.addNode();
   188     Digraph::Node n2 = d.addNode();
   189     Digraph::Node n3 = d.addNode();
   189     Digraph::Node n3 = d.addNode();
   190     Digraph::Node n4 = d.addNode();
   190     Digraph::Node n4 = d.addNode();
   191     Digraph::Node n5 = d.addNode();
   191     Digraph::Node n5 = d.addNode();
   192     
   192 
   193     d.addArc(n1, n2);
   193     d.addArc(n1, n2);
   194     d.addArc(n2, n3);
   194     d.addArc(n2, n3);
   195     d.addArc(n3, n1);
   195     d.addArc(n3, n1);
   196 
   196 
   197     checkDiEulerIt(d);
   197     checkDiEulerIt(d);
   209     Digraph d;
   209     Digraph d;
   210     Graph g(d);
   210     Graph g(d);
   211     Digraph::Node n1 = d.addNode();
   211     Digraph::Node n1 = d.addNode();
   212     Digraph::Node n2 = d.addNode();
   212     Digraph::Node n2 = d.addNode();
   213     Digraph::Node n3 = d.addNode();
   213     Digraph::Node n3 = d.addNode();
   214     
   214 
   215     d.addArc(n1, n2);
   215     d.addArc(n1, n2);
   216     d.addArc(n2, n3);
   216     d.addArc(n2, n3);
   217 
   217 
   218     check(!eulerian(d), "This graph is not Eulerian");
   218     check(!eulerian(d), "This graph is not Eulerian");
   219     check(!eulerian(g), "This graph is not Eulerian");
   219     check(!eulerian(g), "This graph is not Eulerian");