deba@57: /* -*- C++ -*-
deba@57:  *
deba@57:  * This file is a part of LEMON, a generic C++ optimization library
deba@57:  *
alpar@107:  * Copyright (C) 2003-2008
deba@57:  * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
deba@57:  * (Egervary Research Group on Combinatorial Optimization, EGRES).
deba@57:  *
deba@57:  * Permission to use, modify and distribute this software is granted
deba@57:  * provided that this copyright notice appears in all copies. For
deba@57:  * precise terms see the accompanying LICENSE file.
deba@57:  *
deba@57:  * This software is provided "AS IS" with no warranty of any kind,
deba@57:  * express or implied, and with no claim as to its suitability for any
deba@57:  * purpose.
deba@57:  *
deba@57:  */
deba@57: 
deba@57: #include <lemon/concepts/digraph.h>
deba@57: #include <lemon/list_graph.h>
kpeter@171: #include <lemon/smart_graph.h>
deba@57: //#include <lemon/full_graph.h>
deba@57: //#include <lemon/hypercube_graph.h>
deba@57: 
deba@57: #include "test_tools.h"
kpeter@171: #include "graph_test.h"
kpeter@171: #include "graph_maps_test.h"
deba@57: 
deba@57: using namespace lemon;
deba@57: using namespace lemon::concepts;
deba@57: 
kpeter@171: void check_concepts() {
kpeter@171:   { // Checking digraph components
deba@57:     checkConcept<BaseDigraphComponent, BaseDigraphComponent >();
deba@57: 
deba@57:     checkConcept<IDableDigraphComponent<>, 
deba@57:       IDableDigraphComponent<> >();
deba@57: 
deba@57:     checkConcept<IterableDigraphComponent<>, 
deba@57:       IterableDigraphComponent<> >();
deba@57: 
deba@57:     checkConcept<MappableDigraphComponent<>, 
deba@57:       MappableDigraphComponent<> >();
deba@57:   }
kpeter@171:   { // Checking skeleton digraph
deba@57:     checkConcept<Digraph, Digraph>();
deba@57:   }
kpeter@171:   { // Checking ListDigraph
kpeter@171:     checkConcept<Digraph, ListDigraph>();
deba@57:     checkConcept<AlterableDigraphComponent<>, ListDigraph>();
deba@57:     checkConcept<ExtendableDigraphComponent<>, ListDigraph>();
deba@57:     checkConcept<ClearableDigraphComponent<>, ListDigraph>();
deba@57:     checkConcept<ErasableDigraphComponent<>, ListDigraph>();
kpeter@171:     checkDigraphIterators<ListDigraph>();
kpeter@171:   }
kpeter@171:   { // Checking SmartDigraph
kpeter@171:     checkConcept<Digraph, SmartDigraph>();
kpeter@171:     checkConcept<AlterableDigraphComponent<>, SmartDigraph>();
kpeter@171:     checkConcept<ExtendableDigraphComponent<>, SmartDigraph>();
kpeter@171:     checkConcept<ClearableDigraphComponent<>, SmartDigraph>();
kpeter@171:     checkDigraphIterators<SmartDigraph>();
kpeter@171:   }
kpeter@171: //  { // Checking FullDigraph
kpeter@171: //    checkConcept<Digraph, FullDigraph>();
kpeter@171: //    checkDigraphIterators<FullDigraph>();
kpeter@171: //  }
kpeter@171: //  { // Checking HyperCubeDigraph
kpeter@171: //    checkConcept<Digraph, HyperCubeDigraph>();
kpeter@171: //    checkDigraphIterators<HyperCubeDigraph>();
kpeter@171: //  }
kpeter@171: }
deba@57: 
kpeter@171: template <typename Digraph>
kpeter@171: void check_graph_validity() {
kpeter@171:   TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
kpeter@171:   Digraph g;
kpeter@171: 
kpeter@171:   Node
kpeter@171:     n1 = g.addNode(),
kpeter@171:     n2 = g.addNode(),
kpeter@171:     n3 = g.addNode();
kpeter@171: 
kpeter@171:   Arc
kpeter@171:     e1 = g.addArc(n1, n2),
kpeter@171:     e2 = g.addArc(n2, n3);
kpeter@171: 
kpeter@171:   check(g.valid(n1), "Wrong validity check");
kpeter@171:   check(g.valid(e1), "Wrong validity check");
kpeter@171: 
kpeter@171:   check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
kpeter@171:   check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
kpeter@171: }
kpeter@171: 
kpeter@171: template <typename Digraph>
kpeter@171: void check_graph_validity_erase() {
kpeter@171:   TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
kpeter@171:   Digraph g;
kpeter@171: 
kpeter@171:   Node
kpeter@171:     n1 = g.addNode(),
kpeter@171:     n2 = g.addNode(),
kpeter@171:     n3 = g.addNode();
kpeter@171: 
kpeter@171:   Arc
kpeter@171:     e1 = g.addArc(n1, n2),
kpeter@171:     e2 = g.addArc(n2, n3);
kpeter@171: 
kpeter@171:   check(g.valid(n1), "Wrong validity check");
kpeter@171:   check(g.valid(e1), "Wrong validity check");
kpeter@171: 
kpeter@171:   g.erase(n1);
kpeter@171: 
kpeter@171:   check(!g.valid(n1), "Wrong validity check");
kpeter@171:   check(g.valid(n2), "Wrong validity check");
kpeter@171:   check(g.valid(n3), "Wrong validity check");
kpeter@171:   check(!g.valid(e1), "Wrong validity check");
kpeter@171:   check(g.valid(e2), "Wrong validity check");
kpeter@171: 
kpeter@171:   check(!g.valid(g.nodeFromId(-1)), "Wrong validity check");
kpeter@171:   check(!g.valid(g.arcFromId(-1)), "Wrong validity check");
kpeter@171: }
kpeter@171: 
kpeter@171: void check_digraphs() {
kpeter@171:   { // Checking ListDigraph
deba@57:     checkDigraph<ListDigraph>();
deba@57:     checkGraphNodeMap<ListDigraph>();
deba@57:     checkGraphArcMap<ListDigraph>();
kpeter@171: 
kpeter@171:     check_graph_validity_erase<ListDigraph>();
deba@57:   }
kpeter@171:   { // Checking SmartDigraph
kpeter@171:     checkDigraph<SmartDigraph>();
kpeter@171:     checkGraphNodeMap<SmartDigraph>();
kpeter@171:     checkGraphArcMap<SmartDigraph>();
deba@57: 
kpeter@171:     check_graph_validity<SmartDigraph>();
kpeter@171:   }
kpeter@171: }
deba@57: 
kpeter@171: int main() {
kpeter@171:   check_concepts();
kpeter@171:   check_digraphs();
deba@57:   return 0;
deba@57: }