test/graph_copy_test.cc
changeset 1137 ca4e4a5e9b6e
parent 1026 699c7eac2c6d
equal deleted inserted replaced
10:2b67c5889554 11:6d050e396c30
     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-2013
     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
    51       SmartDigraph::Arc arc = from.addArc(fnv[i], fnv[j]);
    51       SmartDigraph::Arc arc = from.addArc(fnv[i], fnv[j]);
    52       fam[arc] = i + j * j;
    52       fam[arc] = i + j * j;
    53       if (i == 0 && j == 0) fa = arc;
    53       if (i == 0 && j == 0) fa = arc;
    54     }
    54     }
    55   }
    55   }
    56   
    56 
    57   // Test digraph copy
    57   // Test digraph copy
    58   GR to;
    58   GR to;
    59   typename GR::template NodeMap<int> tnm(to);
    59   typename GR::template NodeMap<int> tnm(to);
    60   typename GR::template ArcMap<int> tam(to);
    60   typename GR::template ArcMap<int> tam(to);
    61   typename GR::Node tn;
    61   typename GR::Node tn;
    70   digraphCopy(from, to).
    70   digraphCopy(from, to).
    71     nodeMap(fnm, tnm).arcMap(fam, tam).
    71     nodeMap(fnm, tnm).arcMap(fam, tam).
    72     nodeRef(nr).arcRef(er).
    72     nodeRef(nr).arcRef(er).
    73     nodeCrossRef(ncr).arcCrossRef(ecr).
    73     nodeCrossRef(ncr).arcCrossRef(ecr).
    74     node(fn, tn).arc(fa, ta).run();
    74     node(fn, tn).arc(fa, ta).run();
    75   
    75 
    76   check(countNodes(from) == countNodes(to), "Wrong copy.");
    76   check(countNodes(from) == countNodes(to), "Wrong copy.");
    77   check(countArcs(from) == countArcs(to), "Wrong copy.");
    77   check(countArcs(from) == countArcs(to), "Wrong copy.");
    78 
    78 
    79   for (SmartDigraph::NodeIt it(from); it != INVALID; ++it) {
    79   for (SmartDigraph::NodeIt it(from); it != INVALID; ++it) {
    80     check(ncr[nr[it]] == it, "Wrong copy.");
    80     check(ncr[nr[it]] == it, "Wrong copy.");
    98   check(tn == nr[fn], "Wrong copy.");
    98   check(tn == nr[fn], "Wrong copy.");
    99   check(ta == er[fa], "Wrong copy.");
    99   check(ta == er[fa], "Wrong copy.");
   100 
   100 
   101   // Test repeated copy
   101   // Test repeated copy
   102   digraphCopy(from, to).run();
   102   digraphCopy(from, to).run();
   103   
   103 
   104   check(countNodes(from) == countNodes(to), "Wrong copy.");
   104   check(countNodes(from) == countNodes(to), "Wrong copy.");
   105   check(countArcs(from) == countArcs(to), "Wrong copy.");
   105   check(countArcs(from) == countArcs(to), "Wrong copy.");
   106 }
   106 }
   107 
   107 
   108 template <typename GR>
   108 template <typename GR>
   201   check(ta == ar[fa], "Wrong copy.");
   201   check(ta == ar[fa], "Wrong copy.");
   202   check(te == er[fe], "Wrong copy.");
   202   check(te == er[fe], "Wrong copy.");
   203 
   203 
   204   // Test repeated copy
   204   // Test repeated copy
   205   graphCopy(from, to).run();
   205   graphCopy(from, to).run();
   206   
   206 
   207   check(countNodes(from) == countNodes(to), "Wrong copy.");
   207   check(countNodes(from) == countNodes(to), "Wrong copy.");
   208   check(countEdges(from) == countEdges(to), "Wrong copy.");
   208   check(countEdges(from) == countEdges(to), "Wrong copy.");
   209   check(countArcs(from) == countArcs(to), "Wrong copy.");
   209   check(countArcs(from) == countArcs(to), "Wrong copy.");
   210 }
   210 }
   211 
   211 
   364   check(ta == ar[fa], "Wrong copy.");
   364   check(ta == ar[fa], "Wrong copy.");
   365   check(te == er[fe], "Wrong copy.");
   365   check(te == er[fe], "Wrong copy.");
   366 
   366 
   367   // Test repeated copy
   367   // Test repeated copy
   368   bpGraphCopy(from, to).run();
   368   bpGraphCopy(from, to).run();
   369   
   369 
   370   check(countNodes(from) == countNodes(to), "Wrong copy.");
   370   check(countNodes(from) == countNodes(to), "Wrong copy.");
   371   check(countRedNodes(from) == countRedNodes(to), "Wrong copy.");
   371   check(countRedNodes(from) == countRedNodes(to), "Wrong copy.");
   372   check(countBlueNodes(from) == countBlueNodes(to), "Wrong copy.");
   372   check(countBlueNodes(from) == countBlueNodes(to), "Wrong copy.");
   373   check(countEdges(from) == countEdges(to), "Wrong copy.");
   373   check(countEdges(from) == countEdges(to), "Wrong copy.");
   374   check(countArcs(from) == countArcs(to), "Wrong copy.");
   374   check(countArcs(from) == countArcs(to), "Wrong copy.");