test/digraph_test.cc
changeset 822 6cab2ab9d8e7
parent 463 88ed40ad0d4f
child 823 eff1caf6d32e
equal deleted inserted replaced
11:4b543baddeba 15:c8d28fcab9a2
    17  */
    17  */
    18 
    18 
    19 #include <lemon/concepts/digraph.h>
    19 #include <lemon/concepts/digraph.h>
    20 #include <lemon/list_graph.h>
    20 #include <lemon/list_graph.h>
    21 #include <lemon/smart_graph.h>
    21 #include <lemon/smart_graph.h>
       
    22 #include <lemon/static_graph.h>
    22 #include <lemon/full_graph.h>
    23 #include <lemon/full_graph.h>
    23 
    24 
    24 #include "test_tools.h"
    25 #include "test_tools.h"
    25 #include "graph_test.h"
    26 #include "graph_test.h"
    26 
    27 
   315     checkConcept<Digraph, SmartDigraph>();
   316     checkConcept<Digraph, SmartDigraph>();
   316     checkConcept<AlterableDigraphComponent<>, SmartDigraph>();
   317     checkConcept<AlterableDigraphComponent<>, SmartDigraph>();
   317     checkConcept<ExtendableDigraphComponent<>, SmartDigraph>();
   318     checkConcept<ExtendableDigraphComponent<>, SmartDigraph>();
   318     checkConcept<ClearableDigraphComponent<>, SmartDigraph>();
   319     checkConcept<ClearableDigraphComponent<>, SmartDigraph>();
   319   }
   320   }
       
   321   { // Checking StaticDigraph
       
   322     checkConcept<Digraph, StaticDigraph>();
       
   323     checkConcept<ClearableDigraphComponent<>, StaticDigraph>();
       
   324   }
   320   { // Checking FullDigraph
   325   { // Checking FullDigraph
   321     checkConcept<Digraph, FullDigraph>();
   326     checkConcept<Digraph, FullDigraph>();
   322   }
   327   }
   323 }
   328 }
   324 
   329 
   368   check(!g.valid(e1), "Wrong validity check");
   373   check(!g.valid(e1), "Wrong validity check");
   369   check(g.valid(e2), "Wrong validity check");
   374   check(g.valid(e2), "Wrong validity check");
   370 
   375 
   371   check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
   376   check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
   372   check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
   377   check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
       
   378 }
       
   379 
       
   380 void checkStaticDigraph() {
       
   381   SmartDigraph g;
       
   382   SmartDigraph::NodeMap<StaticDigraph::Node> nref(g);
       
   383   SmartDigraph::ArcMap<StaticDigraph::Arc> aref(g);
       
   384   
       
   385   StaticDigraph G;
       
   386   
       
   387   checkGraphNodeList(G, 0);
       
   388   checkGraphArcList(G, 0);
       
   389 
       
   390   G.build(g, nref, aref);
       
   391 
       
   392   checkGraphNodeList(G, 0);
       
   393   checkGraphArcList(G, 0);
       
   394 
       
   395   SmartDigraph::Node
       
   396     n1 = g.addNode(),
       
   397     n2 = g.addNode(),
       
   398     n3 = g.addNode();
       
   399 
       
   400   G.build(g, nref, aref);
       
   401 
       
   402   checkGraphNodeList(G, 3);
       
   403   checkGraphArcList(G, 0);
       
   404 
       
   405   SmartDigraph::Arc a1 = g.addArc(n1, n2);
       
   406 
       
   407   G.build(g, nref, aref);
       
   408 
       
   409   check(G.source(aref[a1]) == nref[n1] && G.target(aref[a1]) == nref[n2],
       
   410         "Wrong arc or wrong references");
       
   411   checkGraphNodeList(G, 3);
       
   412   checkGraphArcList(G, 1);
       
   413 
       
   414   checkGraphOutArcList(G, nref[n1], 1);
       
   415   checkGraphOutArcList(G, nref[n2], 0);
       
   416   checkGraphOutArcList(G, nref[n3], 0);
       
   417 
       
   418   checkGraphInArcList(G, nref[n1], 0);
       
   419   checkGraphInArcList(G, nref[n2], 1);
       
   420   checkGraphInArcList(G, nref[n3], 0);
       
   421 
       
   422   checkGraphConArcList(G, 1);
       
   423 
       
   424   SmartDigraph::Arc
       
   425     a2 = g.addArc(n2, n1),
       
   426     a3 = g.addArc(n2, n3),
       
   427     a4 = g.addArc(n2, n3);
       
   428 
       
   429   digraphCopy(g, G).nodeRef(nref).run();
       
   430 
       
   431   checkGraphNodeList(G, 3);
       
   432   checkGraphArcList(G, 4);
       
   433 
       
   434   checkGraphOutArcList(G, nref[n1], 1);
       
   435   checkGraphOutArcList(G, nref[n2], 3);
       
   436   checkGraphOutArcList(G, nref[n3], 0);
       
   437 
       
   438   checkGraphInArcList(G, nref[n1], 1);
       
   439   checkGraphInArcList(G, nref[n2], 1);
       
   440   checkGraphInArcList(G, nref[n3], 2);
       
   441 
       
   442   checkGraphConArcList(G, 4);
       
   443 
       
   444   checkNodeIds(G);
       
   445   checkArcIds(G);
       
   446   checkGraphNodeMap(G);
       
   447   checkGraphArcMap(G);
   373 }
   448 }
   374 
   449 
   375 void checkFullDigraph(int num) {
   450 void checkFullDigraph(int num) {
   376   typedef FullDigraph Digraph;
   451   typedef FullDigraph Digraph;
   377   DIGRAPH_TYPEDEFS(Digraph);
   452   DIGRAPH_TYPEDEFS(Digraph);
   417     checkDigraphBuild<SmartDigraph>();
   492     checkDigraphBuild<SmartDigraph>();
   418     checkDigraphSplit<SmartDigraph>();
   493     checkDigraphSplit<SmartDigraph>();
   419     checkDigraphSnapshot<SmartDigraph>();
   494     checkDigraphSnapshot<SmartDigraph>();
   420     checkDigraphValidity<SmartDigraph>();
   495     checkDigraphValidity<SmartDigraph>();
   421   }
   496   }
       
   497   { // Checking StaticDigraph
       
   498     checkStaticDigraph();
       
   499   }
   422   { // Checking FullDigraph
   500   { // Checking FullDigraph
   423     checkFullDigraph(8);
   501     checkFullDigraph(8);
   424   }
   502   }
   425 }
   503 }
   426 
   504