test/graph_test.h
changeset 1361 df2d4bf31fcb
parent 1270 dceba191c00d
equal deleted inserted replaced
11:81e424af4a80 12:7ea6846f40be
    36       check(n!=INVALID,"Wrong Node list linking.");
    36       check(n!=INVALID,"Wrong Node list linking.");
    37       ++n;
    37       ++n;
    38     }
    38     }
    39     check(n==INVALID,"Wrong Node list linking.");
    39     check(n==INVALID,"Wrong Node list linking.");
    40     check(countNodes(G)==cnt,"Wrong Node number.");
    40     check(countNodes(G)==cnt,"Wrong Node number.");
       
    41 
       
    42 #ifdef LEMON_CXX11
       
    43     {
       
    44       typename Graph::NodeIt n(G);
       
    45       for(auto u: G.nodes())
       
    46         {
       
    47           check(n==u,"Wrong STL Node iterator.");
       
    48           ++n;
       
    49         }
       
    50       check(n==INVALID,"Wrong STL Node iterator.");
       
    51     }
       
    52     {
       
    53       typename Graph::NodeIt n(G);
       
    54       for(typename Graph::Node u: G.nodes())
       
    55         {
       
    56           check(n==u,"Wrong STL Node iterator.");
       
    57           ++n;
       
    58         }
       
    59       check(n==INVALID,"Wrong STL Node iterator.");
       
    60     }
       
    61 #endif
    41   }
    62   }
    42 
    63 
    43   template<class Graph>
    64   template<class Graph>
    44   void checkGraphRedNodeList(const Graph &G, int cnt)
    65   void checkGraphRedNodeList(const Graph &G, int cnt)
    45   {
    66   {
    54       check(G.asBlueNode(nn) == INVALID,"Wrong node conversion.");
    75       check(G.asBlueNode(nn) == INVALID,"Wrong node conversion.");
    55       ++n;
    76       ++n;
    56     }
    77     }
    57     check(n==INVALID,"Wrong red Node list linking.");
    78     check(n==INVALID,"Wrong red Node list linking.");
    58     check(countRedNodes(G)==cnt,"Wrong red Node number.");
    79     check(countRedNodes(G)==cnt,"Wrong red Node number.");
       
    80 #ifdef LEMON_CXX11
       
    81     {
       
    82       typename Graph::RedNodeIt n(G);
       
    83       for(auto u: G.redNodes())
       
    84         {
       
    85           check(n==u,"Wrong STL RedNode iterator.");
       
    86           ++n;
       
    87         }
       
    88       check(n==INVALID,"Wrong STL RedNode iterator.");
       
    89     }
       
    90     {
       
    91       typename Graph::RedNodeIt n(G);
       
    92       for(typename Graph::RedNode u: G.redNodes())
       
    93         {
       
    94           check(n==u,"Wrong STL RedNode iterator.");
       
    95           ++n;
       
    96         }
       
    97       check(n==INVALID,"Wrong STL RedNode iterator.");
       
    98     }
       
    99 #endif
    59   }
   100   }
    60 
   101 
    61   template<class Graph>
   102   template<class Graph>
    62   void checkGraphBlueNodeList(const Graph &G, int cnt)
   103   void checkGraphBlueNodeList(const Graph &G, int cnt)
    63   {
   104   {
    72       check(G.asRedNode(nn) == INVALID,"Wrong node conversion.");
   113       check(G.asRedNode(nn) == INVALID,"Wrong node conversion.");
    73       ++n;
   114       ++n;
    74     }
   115     }
    75     check(n==INVALID,"Wrong blue Node list linking.");
   116     check(n==INVALID,"Wrong blue Node list linking.");
    76     check(countBlueNodes(G)==cnt,"Wrong blue Node number.");
   117     check(countBlueNodes(G)==cnt,"Wrong blue Node number.");
       
   118 #ifdef LEMON_CXX11
       
   119     {
       
   120       typename Graph::BlueNodeIt n(G);
       
   121       for(auto u: G.blueNodes())
       
   122         {
       
   123           check(n==u,"Wrong STL BlueNode iterator.");
       
   124           ++n;
       
   125         }
       
   126       check(n==INVALID,"Wrong STL BlueNode iterator.");
       
   127     }
       
   128     {
       
   129       typename Graph::BlueNodeIt n(G);
       
   130       for(typename Graph::BlueNode u: G.blueNodes())
       
   131         {
       
   132           check(n==u,"Wrong STL BlueNode iterator.");
       
   133           ++n;
       
   134         }
       
   135       check(n==INVALID,"Wrong STL BlueNode iterator.");
       
   136     }
       
   137 #endif
       
   138 
    77   }
   139   }
    78 
   140 
    79   template<class Graph>
   141   template<class Graph>
    80   void checkGraphArcList(const Graph &G, int cnt)
   142   void checkGraphArcList(const Graph &G, int cnt)
    81   {
   143   {
    88             "Wrong opposite node");
   150             "Wrong opposite node");
    89       ++e;
   151       ++e;
    90     }
   152     }
    91     check(e==INVALID,"Wrong Arc list linking.");
   153     check(e==INVALID,"Wrong Arc list linking.");
    92     check(countArcs(G)==cnt,"Wrong Arc number.");
   154     check(countArcs(G)==cnt,"Wrong Arc number.");
       
   155 #ifdef LEMON_CXX11
       
   156     {
       
   157       typename Graph::ArcIt a(G);
       
   158       for(auto e: G.arcs())
       
   159         {
       
   160           check(a==e,"Wrong STL Arc iterator.");
       
   161           ++a;
       
   162         }
       
   163       check(a==INVALID,"Wrong STL Arc iterator.");
       
   164     }
       
   165     {
       
   166       typename Graph::ArcIt a(G);
       
   167       for(typename Graph::Arc e: G.arcs())
       
   168         {
       
   169           check(a==e,"Wrong STL Arc iterator.");
       
   170           ++a;
       
   171         }
       
   172       check(a==INVALID,"Wrong STL Arc iterator.");
       
   173     }
       
   174 #endif
       
   175 
    93   }
   176   }
    94 
   177 
    95   template<class Graph>
   178   template<class Graph>
    96   void checkGraphOutArcList(const Graph &G, typename Graph::Node n, int cnt)
   179   void checkGraphOutArcList(const Graph &G, typename Graph::Node n, int cnt)
    97   {
   180   {
   103       check(G.target(e)==G.runningNode(e),"Wrong OutArc list linking.");
   186       check(G.target(e)==G.runningNode(e),"Wrong OutArc list linking.");
   104       ++e;
   187       ++e;
   105     }
   188     }
   106     check(e==INVALID,"Wrong OutArc list linking.");
   189     check(e==INVALID,"Wrong OutArc list linking.");
   107     check(countOutArcs(G,n)==cnt,"Wrong OutArc number.");
   190     check(countOutArcs(G,n)==cnt,"Wrong OutArc number.");
       
   191 #ifdef LEMON_CXX11
       
   192     {
       
   193       typename Graph::OutArcIt a(G,n);
       
   194       for(auto e: G.outArcs(n))
       
   195         {
       
   196           check(a==e,"Wrong STL OutArc iterator.");
       
   197           ++a;
       
   198         }
       
   199       check(a==INVALID,"Wrong STL OutArc iterator.");
       
   200     }
       
   201     {
       
   202       typename Graph::OutArcIt a(G,n);
       
   203       for(typename Graph::Arc e: G.outArcs(n))
       
   204         {
       
   205           check(a==e,"Wrong STL OutArc iterator.");
       
   206           ++a;
       
   207         }
       
   208       check(a==INVALID,"Wrong STL OutArc iterator.");
       
   209     }
       
   210 #endif
       
   211 
   108   }
   212   }
   109 
   213 
   110   template<class Graph>
   214   template<class Graph>
   111   void checkGraphInArcList(const Graph &G, typename Graph::Node n, int cnt)
   215   void checkGraphInArcList(const Graph &G, typename Graph::Node n, int cnt)
   112   {
   216   {
   118       check(G.source(e)==G.runningNode(e),"Wrong OutArc list linking.");
   222       check(G.source(e)==G.runningNode(e),"Wrong OutArc list linking.");
   119       ++e;
   223       ++e;
   120     }
   224     }
   121     check(e==INVALID,"Wrong InArc list linking.");
   225     check(e==INVALID,"Wrong InArc list linking.");
   122     check(countInArcs(G,n)==cnt,"Wrong InArc number.");
   226     check(countInArcs(G,n)==cnt,"Wrong InArc number.");
       
   227 #ifdef LEMON_CXX11
       
   228     {
       
   229       typename Graph::InArcIt a(G,n);
       
   230       for(auto e: G.inArcs(n))
       
   231         {
       
   232           check(a==e,"Wrong STL InArc iterator.");
       
   233           ++a;
       
   234         }
       
   235       check(a==INVALID,"Wrong STL InArc iterator.");
       
   236     }
       
   237     {
       
   238       typename Graph::InArcIt a(G,n);
       
   239       for(typename Graph::Arc e: G.inArcs(n))
       
   240         {
       
   241           check(a==e,"Wrong STL InArc iterator.");
       
   242           ++a;
       
   243         }
       
   244       check(a==INVALID,"Wrong STL InArc iterator.");
       
   245     }
       
   246 #endif
   123   }
   247   }
   124 
   248 
   125   template<class Graph>
   249   template<class Graph>
   126   void checkGraphEdgeList(const Graph &G, int cnt)
   250   void checkGraphEdgeList(const Graph &G, int cnt)
   127   {
   251   {
   132       check(G.oppositeNode(G.v(e), e) == G.u(e), "Wrong opposite node");
   256       check(G.oppositeNode(G.v(e), e) == G.u(e), "Wrong opposite node");
   133       ++e;
   257       ++e;
   134     }
   258     }
   135     check(e==INVALID,"Wrong Edge list linking.");
   259     check(e==INVALID,"Wrong Edge list linking.");
   136     check(countEdges(G)==cnt,"Wrong Edge number.");
   260     check(countEdges(G)==cnt,"Wrong Edge number.");
       
   261 #ifdef LEMON_CXX11
       
   262     {
       
   263       typename Graph::EdgeIt a(G);
       
   264       for(auto e: G.edges())
       
   265         {
       
   266           check(a==e,"Wrong STL Edge iterator.");
       
   267           ++a;
       
   268         }
       
   269       check(a==INVALID,"Wrong STL Edge iterator.");
       
   270     }
       
   271     {
       
   272       typename Graph::EdgeIt a(G);
       
   273       for(typename Graph::Edge e: G.edges())
       
   274         {
       
   275           check(a==e,"Wrong STL Edge iterator.");
       
   276           ++a;
       
   277         }
       
   278       check(a==INVALID,"Wrong STL Edge iterator.");
       
   279     }
       
   280 #endif
       
   281 
   137   }
   282   }
   138 
   283 
   139   template<class Graph>
   284   template<class Graph>
   140   void checkGraphIncEdgeList(const Graph &G, typename Graph::Node n, int cnt)
   285   void checkGraphIncEdgeList(const Graph &G, typename Graph::Node n, int cnt)
   141   {
   286   {
   148             "Wrong OutArc list linking.");
   293             "Wrong OutArc list linking.");
   149       ++e;
   294       ++e;
   150     }
   295     }
   151     check(e==INVALID,"Wrong IncEdge list linking.");
   296     check(e==INVALID,"Wrong IncEdge list linking.");
   152     check(countIncEdges(G,n)==cnt,"Wrong IncEdge number.");
   297     check(countIncEdges(G,n)==cnt,"Wrong IncEdge number.");
       
   298 #ifdef LEMON_CXX11
       
   299     {
       
   300       typename Graph::IncEdgeIt a(G,n);
       
   301       for(auto e: G.incEdges(n))
       
   302         {
       
   303           check(a==e,"Wrong STL IncEdge iterator.");
       
   304           ++a;
       
   305         }
       
   306       check(a==INVALID,"Wrong STL IncEdge iterator.");
       
   307     }
       
   308     {
       
   309       typename Graph::IncEdgeIt a(G,n);
       
   310       for(typename Graph::Edge e: G.incEdges(n))
       
   311         {
       
   312           check(a==e,"Wrong STL IncEdge iterator.");
       
   313           ++a;
       
   314         }
       
   315       check(a==INVALID,"Wrong STL IncEdge iterator.");
       
   316     }
       
   317 #endif
       
   318 
   153   }
   319   }
   154 
   320 
   155   template <class Graph>
   321   template <class Graph>
   156   void checkGraphIncEdgeArcLists(const Graph &G, typename Graph::Node n,
   322   void checkGraphIncEdgeArcLists(const Graph &G, typename Graph::Node n,
   157                                  int cnt)
   323                                  int cnt)