| 1 | /* -*- mode: C++; indent-tabs-mode: nil; -*- |
| 2 | * |
| 3 | * This file has been adapted by Nicolas Bonneel (2013), |
| 4 | * from full_graph.h from LEMON, a generic C++ optimization library, |
| 5 | * to make the other files independant from the rest of |
| 6 | * the original library. |
| 7 | * |
| 8 | * |
| 9 | **** Original file Copyright Notice : |
| 10 | * Copyright (C) 2003-2010 |
| 11 | * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
| 12 | * (Egervary Research Group on Combinatorial Optimization, EGRES). |
| 13 | * |
| 14 | * Permission to use, modify and distribute this software is granted |
| 15 | * provided that this copyright notice appears in all copies. For |
| 16 | * precise terms see the accompanying LICENSE file. |
| 17 | * |
| 18 | * This software is provided "AS IS" with no warranty of any kind, |
| 19 | * express or implied, and with no claim as to its suitability for any |
| 20 | * purpose. |
| 21 | * |
| 22 | */ |
| 23 | |
| 24 | #ifndef LEMON_CORE_H |
| 25 | #define LEMON_CORE_H |
| 26 | |
| 27 | #include <vector> |
| 28 | #include <algorithm> |
| 29 | |
| 30 | |
| 31 | // Disable the following warnings when compiling with MSVC: |
| 32 | // C4250: 'class1' : inherits 'class2::member' via dominance |
| 33 | // C4355: 'this' : used in base member initializer list |
| 34 | // C4503: 'function' : decorated name length exceeded, name was truncated |
| 35 | // C4800: 'type' : forcing value to bool 'true' or 'false' (performance warning) |
| 36 | // C4996: 'function': was declared deprecated |
| 37 | #ifdef _MSC_VER |
| 38 | #pragma warning( disable : 4250 4355 4503 4800 4996 ) |
| 39 | #endif |
| 40 | |
| 41 | ///\file |
| 42 | ///\brief LEMON core utilities. |
| 43 | /// |
| 44 | ///This header file contains core utilities for LEMON. |
| 45 | ///It is automatically included by all graph types, therefore it usually |
| 46 | ///do not have to be included directly. |
| 47 | |
| 48 | namespace lemon { |
| 49 | |
| 50 | /// \brief Dummy type to make it easier to create invalid iterators. |
| 51 | /// |
| 52 | /// Dummy type to make it easier to create invalid iterators. |
| 53 | /// See \ref INVALID for the usage. |
| 54 | struct Invalid { |
| 55 | public: |
| 56 | bool operator==(Invalid) { return true; } |
| 57 | bool operator!=(Invalid) { return false; } |
| 58 | bool operator< (Invalid) { return false; } |
| 59 | }; |
| 60 | |
| 61 | /// \brief Invalid iterators. |
| 62 | /// |
| 63 | /// \ref Invalid is a global type that converts to each iterator |
| 64 | /// in such a way that the value of the target iterator will be invalid. |
| 65 | #ifdef LEMON_ONLY_TEMPLATES |
| 66 | const Invalid INVALID = Invalid(); |
| 67 | #else |
| 68 | extern const Invalid INVALID; |
| 69 | #endif |
| 70 | |
| 71 | /// \addtogroup gutils |
| 72 | /// @{ |
| 73 | |
| 74 | ///Create convenience typedefs for the digraph types and iterators |
| 75 | |
| 76 | ///This \c \#define creates convenient type definitions for the following |
| 77 | ///types of \c Digraph: \c Node, \c NodeIt, \c Arc, \c ArcIt, \c InArcIt, |
| 78 | ///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap, |
| 79 | ///\c BoolArcMap, \c IntArcMap, \c DoubleArcMap. |
| 80 | /// |
| 81 | ///\note If the graph type is a dependent type, ie. the graph type depend |
| 82 | ///on a template parameter, then use \c TEMPLATE_DIGRAPH_TYPEDEFS() |
| 83 | ///macro. |
| 84 | #define DIGRAPH_TYPEDEFS(Digraph) \ |
| 85 | typedef Digraph::Node Node; \ |
| 86 | typedef Digraph::Arc Arc; \ |
| 87 | |
| 88 | |
| 89 | ///Create convenience typedefs for the digraph types and iterators |
| 90 | |
| 91 | ///\see DIGRAPH_TYPEDEFS |
| 92 | /// |
| 93 | ///\note Use this macro, if the graph type is a dependent type, |
| 94 | ///ie. the graph type depend on a template parameter. |
| 95 | #define TEMPLATE_DIGRAPH_TYPEDEFS(Digraph) \ |
| 96 | typedef typename Digraph::Node Node; \ |
| 97 | typedef typename Digraph::Arc Arc; \ |
| 98 | |
| 99 | |
| 100 | |
| 101 | } //namespace lemon |
| 102 | |
| 103 | #endif |