0
16
0
1
1
1 | 1 |
LEMON code without an explicit copyright is covered by the following |
2 | 2 |
copyright/license. |
3 | 3 |
|
4 |
Copyright (C) 2003- |
|
4 |
Copyright (C) 2003-2008 Egervary Jeno Kombinatorikus Optimalizalasi |
|
5 | 5 |
Kutatocsoport (Egervary Combinatorial Optimization Research Group, |
6 | 6 |
EGRES). |
7 | 7 |
|
8 | 8 |
Permission is hereby granted, free of charge, to any person or organization |
9 | 9 |
obtaining a copy of the software and accompanying documentation covered by |
10 | 10 |
this license (the "Software") to use, reproduce, display, distribute, |
11 | 11 |
execute, and transmit the Software, and to prepare derivative works of the |
12 | 12 |
Software, and to permit third-parties to whom the Software is furnished to |
13 | 13 |
do so, all subject to the following: |
14 | 14 |
|
15 | 15 |
The copyright notices in the Software and this entire statement, including |
16 | 16 |
the above license grant, this restriction and the following disclaimer, |
17 | 17 |
must be included in all copies of the Software, in whole or in part, and |
18 | 18 |
all derivative works of the Software, unless such copies or derivative |
19 | 19 |
works are solely in the form of machine-executable object code generated by |
20 | 20 |
a source language processor. |
21 | 21 |
|
22 | 22 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
23 | 23 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
24 | 24 |
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT |
25 | 25 |
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE |
26 | 26 |
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, |
27 | 27 |
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
28 | 28 |
DEALINGS IN THE SOFTWARE. |
29 | 29 |
|
30 | 30 |
=========================================================================== |
31 | 31 |
This license is a verbatim copy of the Boost Software License, Version 1.0. |
32 | 32 |
|
33 | 33 |
1 | 1 |
/* -*- C++ -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2008 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_ALTERATION_NOTIFIER_H |
20 | 20 |
#define LEMON_BITS_ALTERATION_NOTIFIER_H |
21 | 21 |
|
22 | 22 |
#include <vector> |
23 | 23 |
#include <list> |
24 | 24 |
|
25 | 25 |
#include <lemon/bits/utility.h> |
26 | 26 |
|
27 | 27 |
///\ingroup graphbits |
28 | 28 |
///\file |
29 | 29 |
///\brief Observer notifier for graph alteration observers. |
30 | 30 |
|
31 | 31 |
namespace lemon { |
32 | 32 |
|
33 | 33 |
/// \ingroup graphbits |
34 | 34 |
/// |
35 | 35 |
/// \brief Notifier class to notify observes about alterations in |
36 | 36 |
/// a container. |
37 | 37 |
/// |
38 | 38 |
/// The simple graph's can be refered as two containers, one node container |
39 | 39 |
/// and one edge container. But they are not standard containers they |
40 | 40 |
/// does not store values directly they are just key continars for more |
41 | 41 |
/// value containers which are the node and edge maps. |
42 | 42 |
/// |
43 | 43 |
/// The graph's node and edge sets can be changed as we add or erase |
44 | 44 |
/// nodes and edges in the graph. Lemon would like to handle easily |
45 | 45 |
/// that the node and edge maps should contain values for all nodes or |
46 | 46 |
/// edges. If we want to check on every indicing if the map contains |
47 | 47 |
/// the current indicing key that cause a drawback in the performance |
48 | 48 |
/// in the library. We use another solution we notify all maps about |
49 | 49 |
/// an alteration in the graph, which cause only drawback on the |
50 | 50 |
/// alteration of the graph. |
51 | 51 |
/// |
52 | 52 |
/// This class provides an interface to the container. The \e first() and \e |
53 | 53 |
/// next() member functions make possible to iterate on the keys of the |
1 | 1 |
/* -*- C++ -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2008 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_ARRAY_MAP_H |
20 | 20 |
#define LEMON_BITS_ARRAY_MAP_H |
21 | 21 |
|
22 | 22 |
#include <memory> |
23 | 23 |
|
24 | 24 |
#include <lemon/bits/traits.h> |
25 | 25 |
#include <lemon/bits/alteration_notifier.h> |
26 | 26 |
#include <lemon/concept_check.h> |
27 | 27 |
#include <lemon/concepts/maps.h> |
28 | 28 |
|
29 | 29 |
/// \ingroup graphbits |
30 | 30 |
/// \file |
31 | 31 |
/// \brief Graph map based on the array storage. |
32 | 32 |
|
33 | 33 |
namespace lemon { |
34 | 34 |
|
35 | 35 |
/// \ingroup graphbits |
36 | 36 |
/// |
37 | 37 |
/// \brief Graph map based on the array storage. |
38 | 38 |
/// |
39 | 39 |
/// The ArrayMap template class is graph map structure what |
40 | 40 |
/// automatically updates the map when a key is added to or erased from |
41 | 41 |
/// the map. This map uses the allocators to implement |
42 | 42 |
/// the container functionality. |
43 | 43 |
/// |
44 | 44 |
/// The template parameters are the Graph the current Item type and |
45 | 45 |
/// the Value type of the map. |
46 | 46 |
template <typename _Graph, typename _Item, typename _Value> |
47 | 47 |
class ArrayMap |
48 | 48 |
: public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase { |
49 | 49 |
public: |
50 | 50 |
/// The graph type of the maps. |
51 | 51 |
typedef _Graph Graph; |
52 | 52 |
/// The item type of the map. |
53 | 53 |
typedef _Item Item; |
1 | 1 |
/* -*- C++ -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2008 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_BASE_EXTENDER_H |
20 | 20 |
#define LEMON_BITS_BASE_EXTENDER_H |
21 | 21 |
|
22 | 22 |
#include <lemon/bits/invalid.h> |
23 | 23 |
#include <lemon/error.h> |
24 | 24 |
|
25 | 25 |
#include <lemon/bits/map_extender.h> |
26 | 26 |
#include <lemon/bits/default_map.h> |
27 | 27 |
|
28 | 28 |
#include <lemon/concept_check.h> |
29 | 29 |
#include <lemon/concepts/maps.h> |
30 | 30 |
|
31 | 31 |
///\ingroup digraphbits |
32 | 32 |
///\file |
33 | 33 |
///\brief Extenders for the digraph types |
34 | 34 |
namespace lemon { |
35 | 35 |
|
36 | 36 |
/// \ingroup digraphbits |
37 | 37 |
/// |
38 | 38 |
/// \brief BaseDigraph to BaseGraph extender |
39 | 39 |
template <typename Base> |
40 | 40 |
class UndirDigraphExtender : public Base { |
41 | 41 |
|
42 | 42 |
public: |
43 | 43 |
|
44 | 44 |
typedef Base Parent; |
45 | 45 |
typedef typename Parent::Arc Edge; |
46 | 46 |
typedef typename Parent::Node Node; |
47 | 47 |
|
48 | 48 |
typedef True UndirectedTag; |
49 | 49 |
|
50 | 50 |
class Arc : public Edge { |
51 | 51 |
friend class UndirDigraphExtender; |
52 | 52 |
|
53 | 53 |
protected: |
1 | 1 |
/* -*- C++ -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2008 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_DEFAULT_MAP_H |
20 | 20 |
#define LEMON_BITS_DEFAULT_MAP_H |
21 | 21 |
|
22 | 22 |
|
23 | 23 |
#include <lemon/bits/array_map.h> |
24 | 24 |
#include <lemon/bits/vector_map.h> |
25 | 25 |
//#include <lemon/bits/debug_map.h> |
26 | 26 |
|
27 | 27 |
///\ingroup graphbits |
28 | 28 |
///\file |
29 | 29 |
///\brief Graph maps that construct and destruct their elements dynamically. |
30 | 30 |
|
31 | 31 |
namespace lemon { |
32 | 32 |
|
33 | 33 |
|
34 | 34 |
//#ifndef LEMON_USE_DEBUG_MAP |
35 | 35 |
|
36 | 36 |
template <typename _Graph, typename _Item, typename _Value> |
37 | 37 |
struct DefaultMapSelector { |
38 | 38 |
typedef ArrayMap<_Graph, _Item, _Value> Map; |
39 | 39 |
}; |
40 | 40 |
|
41 | 41 |
// bool |
42 | 42 |
template <typename _Graph, typename _Item> |
43 | 43 |
struct DefaultMapSelector<_Graph, _Item, bool> { |
44 | 44 |
typedef VectorMap<_Graph, _Item, bool> Map; |
45 | 45 |
}; |
46 | 46 |
|
47 | 47 |
// char |
48 | 48 |
template <typename _Graph, typename _Item> |
49 | 49 |
struct DefaultMapSelector<_Graph, _Item, char> { |
50 | 50 |
typedef VectorMap<_Graph, _Item, char> Map; |
51 | 51 |
}; |
52 | 52 |
|
53 | 53 |
template <typename _Graph, typename _Item> |
1 | 1 |
/* -*- C++ -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2008 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_GRAPH_EXTENDER_H |
20 | 20 |
#define LEMON_BITS_GRAPH_EXTENDER_H |
21 | 21 |
|
22 | 22 |
#include <lemon/bits/invalid.h> |
23 | 23 |
#include <lemon/bits/utility.h> |
24 | 24 |
|
25 | 25 |
#include <lemon/bits/map_extender.h> |
26 | 26 |
#include <lemon/bits/default_map.h> |
27 | 27 |
|
28 | 28 |
#include <lemon/concept_check.h> |
29 | 29 |
#include <lemon/concepts/maps.h> |
30 | 30 |
|
31 | 31 |
///\ingroup graphbits |
32 | 32 |
///\file |
33 | 33 |
///\brief Extenders for the digraph types |
34 | 34 |
namespace lemon { |
35 | 35 |
|
36 | 36 |
/// \ingroup graphbits |
37 | 37 |
/// |
38 | 38 |
/// \brief Extender for the Digraphs |
39 | 39 |
template <typename Base> |
40 | 40 |
class DigraphExtender : public Base { |
41 | 41 |
public: |
42 | 42 |
|
43 | 43 |
typedef Base Parent; |
44 | 44 |
typedef DigraphExtender Digraph; |
45 | 45 |
|
46 | 46 |
// Base extensions |
47 | 47 |
|
48 | 48 |
typedef typename Parent::Node Node; |
49 | 49 |
typedef typename Parent::Arc Arc; |
50 | 50 |
|
51 | 51 |
int maxId(Node) const { |
52 | 52 |
return Parent::maxNodeId(); |
53 | 53 |
} |
1 | 1 |
/* -*- C++ -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2008 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_MAP_EXTENDER_H |
20 | 20 |
#define LEMON_BITS_MAP_EXTENDER_H |
21 | 21 |
|
22 | 22 |
#include <iterator> |
23 | 23 |
|
24 | 24 |
#include <lemon/bits/traits.h> |
25 | 25 |
|
26 | 26 |
#include <lemon/concept_check.h> |
27 | 27 |
#include <lemon/concepts/maps.h> |
28 | 28 |
|
29 | 29 |
///\file |
30 | 30 |
///\brief Extenders for iterable maps. |
31 | 31 |
|
32 | 32 |
namespace lemon { |
33 | 33 |
|
34 | 34 |
/// \ingroup graphbits |
35 | 35 |
/// |
36 | 36 |
/// \brief Extender for maps |
37 | 37 |
template <typename _Map> |
38 | 38 |
class MapExtender : public _Map { |
39 | 39 |
public: |
40 | 40 |
|
41 | 41 |
typedef _Map Parent; |
42 | 42 |
typedef MapExtender Map; |
43 | 43 |
|
44 | 44 |
|
45 | 45 |
typedef typename Parent::Graph Graph; |
46 | 46 |
typedef typename Parent::Key Item; |
47 | 47 |
|
48 | 48 |
typedef typename Parent::Key Key; |
49 | 49 |
typedef typename Parent::Value Value; |
50 | 50 |
|
51 | 51 |
class MapIt; |
52 | 52 |
class ConstMapIt; |
53 | 53 |
1 | 1 |
|
2 | 2 |
/* -*- C++ -*- |
3 | 3 |
* |
4 | 4 |
* This file is a part of LEMON, a generic C++ optimization library |
5 | 5 |
* |
6 |
* Copyright (C) 2003- |
|
6 |
* Copyright (C) 2003-2008 |
|
7 | 7 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
8 | 8 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
9 | 9 |
* |
10 | 10 |
* Permission to use, modify and distribute this software is granted |
11 | 11 |
* provided that this copyright notice appears in all copies. For |
12 | 12 |
* precise terms see the accompanying LICENSE file. |
13 | 13 |
* |
14 | 14 |
* This software is provided "AS IS" with no warranty of any kind, |
15 | 15 |
* express or implied, and with no claim as to its suitability for any |
16 | 16 |
* purpose. |
17 | 17 |
* |
18 | 18 |
*/ |
19 | 19 |
|
20 | 20 |
#ifndef LEMON_BITS_TRAITS_H |
21 | 21 |
#define LEMON_BITS_TRAITS_H |
22 | 22 |
|
23 | 23 |
#include <lemon/bits/utility.h> |
24 | 24 |
|
25 | 25 |
///\file |
26 | 26 |
///\brief Traits for graphs and maps |
27 | 27 |
/// |
28 | 28 |
|
29 | 29 |
namespace lemon { |
30 | 30 |
template <typename _Graph, typename _Item> |
31 | 31 |
class ItemSetTraits {}; |
32 | 32 |
|
33 | 33 |
|
34 | 34 |
template <typename Graph, typename Enable = void> |
35 | 35 |
struct NodeNotifierIndicator { |
36 | 36 |
typedef InvalidType Type; |
37 | 37 |
}; |
38 | 38 |
template <typename Graph> |
39 | 39 |
struct NodeNotifierIndicator< |
40 | 40 |
Graph, |
41 | 41 |
typename enable_if<typename Graph::NodeNotifier::Notifier, void>::type |
42 | 42 |
> { |
43 | 43 |
typedef typename Graph::NodeNotifier Type; |
44 | 44 |
}; |
45 | 45 |
|
46 | 46 |
template <typename _Graph> |
47 | 47 |
class ItemSetTraits<_Graph, typename _Graph::Node> { |
48 | 48 |
public: |
49 | 49 |
|
50 | 50 |
typedef _Graph Graph; |
51 | 51 |
|
52 | 52 |
typedef typename Graph::Node Item; |
53 | 53 |
typedef typename Graph::NodeIt ItemIt; |
54 | 54 |
1 | 1 |
/* -*- C++ -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2008 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_VECTOR_MAP_H |
20 | 20 |
#define LEMON_BITS_VECTOR_MAP_H |
21 | 21 |
|
22 | 22 |
#include <vector> |
23 | 23 |
#include <algorithm> |
24 | 24 |
|
25 | 25 |
#include <lemon/bits/traits.h> |
26 | 26 |
#include <lemon/bits/utility.h> |
27 | 27 |
|
28 | 28 |
#include <lemon/bits/alteration_notifier.h> |
29 | 29 |
|
30 | 30 |
#include <lemon/concept_check.h> |
31 | 31 |
#include <lemon/concepts/maps.h> |
32 | 32 |
|
33 | 33 |
///\ingroup graphbits |
34 | 34 |
/// |
35 | 35 |
///\file |
36 | 36 |
///\brief Vector based graph maps. |
37 | 37 |
namespace lemon { |
38 | 38 |
|
39 | 39 |
/// \ingroup graphbits |
40 | 40 |
/// |
41 | 41 |
/// \brief Graph map based on the std::vector storage. |
42 | 42 |
/// |
43 | 43 |
/// The VectorMap template class is graph map structure what |
44 | 44 |
/// automatically updates the map when a key is added to or erased from |
45 | 45 |
/// the map. This map type uses the std::vector to store the values. |
46 | 46 |
/// |
47 | 47 |
/// \param Notifier The AlterationNotifier that will notify this map. |
48 | 48 |
/// \param Item The item type of the graph items. |
49 | 49 |
/// \param Value The value type of the map. |
50 | 50 |
/// |
51 | 51 |
/// \author Balazs Dezso |
52 | 52 |
template <typename _Graph, typename _Item, typename _Value> |
53 | 53 |
class VectorMap |
1 | 1 |
/* -*- C++ -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2008 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_CONCEPT_DIGRAPH_H |
20 | 20 |
#define LEMON_CONCEPT_DIGRAPH_H |
21 | 21 |
|
22 | 22 |
///\ingroup graph_concepts |
23 | 23 |
///\file |
24 | 24 |
///\brief The concept of directed graphs. |
25 | 25 |
|
26 | 26 |
#include <lemon/bits/invalid.h> |
27 | 27 |
#include <lemon/bits/utility.h> |
28 | 28 |
#include <lemon/concepts/maps.h> |
29 | 29 |
#include <lemon/concept_check.h> |
30 | 30 |
#include <lemon/concepts/graph_components.h> |
31 | 31 |
|
32 | 32 |
namespace lemon { |
33 | 33 |
namespace concepts { |
34 | 34 |
|
35 | 35 |
/// \ingroup graph_concepts |
36 | 36 |
/// |
37 | 37 |
/// \brief Class describing the concept of directed graphs. |
38 | 38 |
/// |
39 | 39 |
/// This class describes the \ref concept "concept" of the |
40 | 40 |
/// immutable directed digraphs. |
41 | 41 |
/// |
42 | 42 |
/// Note that actual digraph implementation like @ref ListDigraph or |
43 | 43 |
/// @ref SmartDigraph may have several additional functionality. |
44 | 44 |
/// |
45 | 45 |
/// \sa concept |
46 | 46 |
class Digraph { |
47 | 47 |
private: |
48 | 48 |
///Digraphs are \e not copy constructible. Use DigraphCopy() instead. |
49 | 49 |
|
50 | 50 |
///Digraphs are \e not copy constructible. Use DigraphCopy() instead. |
51 | 51 |
/// |
52 | 52 |
Digraph(const Digraph &) {}; |
53 | 53 |
///\brief Assignment of \ref Digraph "Digraph"s to another ones are |
1 | 1 |
/* -*- C++ -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2008 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
///\ingroup graph_concepts |
20 | 20 |
///\file |
21 | 21 |
///\brief The concept of Undirected Graphs. |
22 | 22 |
|
23 | 23 |
#ifndef LEMON_CONCEPT_GRAPH_H |
24 | 24 |
#define LEMON_CONCEPT_GRAPH_H |
25 | 25 |
|
26 | 26 |
#include <lemon/concepts/graph_components.h> |
27 | 27 |
#include <lemon/concepts/graph.h> |
28 | 28 |
#include <lemon/bits/utility.h> |
29 | 29 |
|
30 | 30 |
namespace lemon { |
31 | 31 |
namespace concepts { |
32 | 32 |
|
33 | 33 |
/// \ingroup graph_concepts |
34 | 34 |
/// |
35 | 35 |
/// \brief Class describing the concept of Undirected Graphs. |
36 | 36 |
/// |
37 | 37 |
/// This class describes the common interface of all Undirected |
38 | 38 |
/// Graphs. |
39 | 39 |
/// |
40 | 40 |
/// As all concept describing classes it provides only interface |
41 | 41 |
/// without any sensible implementation. So any algorithm for |
42 | 42 |
/// undirected graph should compile with this class, but it will not |
43 | 43 |
/// run properly, of course. |
44 | 44 |
/// |
45 | 45 |
/// The LEMON undirected graphs also fulfill the concept of |
46 | 46 |
/// directed graphs (\ref lemon::concepts::Digraph "Digraph |
47 | 47 |
/// Concept"). Each edges can be seen as two opposite |
48 | 48 |
/// directed arc and consequently the undirected graph can be |
49 | 49 |
/// seen as the direceted graph of these directed arcs. The |
50 | 50 |
/// Graph has the Edge inner class for the edges and |
51 | 51 |
/// the Arc type for the directed arcs. The Arc type is |
52 | 52 |
/// convertible to Edge or inherited from it so from a directed |
53 | 53 |
/// arc we can get the represented edge. |
1 | 1 |
/* -*- C++ -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2008 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
///\ingroup graph_concepts |
20 | 20 |
///\file |
21 | 21 |
///\brief The concept of graph components. |
22 | 22 |
|
23 | 23 |
|
24 | 24 |
#ifndef LEMON_CONCEPT_GRAPH_COMPONENTS_H |
25 | 25 |
#define LEMON_CONCEPT_GRAPH_COMPONENTS_H |
26 | 26 |
|
27 | 27 |
#include <lemon/bits/invalid.h> |
28 | 28 |
#include <lemon/concepts/maps.h> |
29 | 29 |
|
30 | 30 |
#include <lemon/bits/alteration_notifier.h> |
31 | 31 |
|
32 | 32 |
namespace lemon { |
33 | 33 |
namespace concepts { |
34 | 34 |
|
35 | 35 |
/// \brief Skeleton class for graph Node and Arc types |
36 | 36 |
/// |
37 | 37 |
/// This class describes the interface of Node and Arc (and Edge |
38 | 38 |
/// in undirected graphs) subtypes of graph types. |
39 | 39 |
/// |
40 | 40 |
/// \note This class is a template class so that we can use it to |
41 | 41 |
/// create graph skeleton classes. The reason for this is than Node |
42 | 42 |
/// and Arc types should \em not derive from the same base class. |
43 | 43 |
/// For Node you should instantiate it with character 'n' and for Arc |
44 | 44 |
/// with 'a'. |
45 | 45 |
|
46 | 46 |
#ifndef DOXYGEN |
47 | 47 |
template <char _selector = '0'> |
48 | 48 |
#endif |
49 | 49 |
class GraphItem { |
50 | 50 |
public: |
51 | 51 |
/// \brief Default constructor. |
52 | 52 |
/// |
53 | 53 |
/// \warning The default constructor is not required to set |
1 | 1 |
/* -*- C++ -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2008 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#include <iostream> |
20 | 20 |
#include <vector> |
21 | 21 |
|
22 | 22 |
#include <lemon/concepts/digraph.h> |
23 | 23 |
#include <lemon/list_graph.h> |
24 | 24 |
//#include <lemon/smart_graph.h> |
25 | 25 |
//#include <lemon/full_graph.h> |
26 | 26 |
//#include <lemon/hypercube_graph.h> |
27 | 27 |
|
28 | 28 |
#include "test_tools.h" |
29 | 29 |
#include "digraph_test.h" |
30 | 30 |
#include "map_test.h" |
31 | 31 |
|
32 | 32 |
|
33 | 33 |
using namespace lemon; |
34 | 34 |
using namespace lemon::concepts; |
35 | 35 |
|
36 | 36 |
|
37 | 37 |
int main() { |
38 | 38 |
{ // checking digraph components |
39 | 39 |
checkConcept<BaseDigraphComponent, BaseDigraphComponent >(); |
40 | 40 |
|
41 | 41 |
checkConcept<IDableDigraphComponent<>, |
42 | 42 |
IDableDigraphComponent<> >(); |
43 | 43 |
|
44 | 44 |
checkConcept<IterableDigraphComponent<>, |
45 | 45 |
IterableDigraphComponent<> >(); |
46 | 46 |
|
47 | 47 |
checkConcept<MappableDigraphComponent<>, |
48 | 48 |
MappableDigraphComponent<> >(); |
49 | 49 |
|
50 | 50 |
} |
51 | 51 |
{ // checking skeleton digraphs |
52 | 52 |
checkConcept<Digraph, Digraph>(); |
53 | 53 |
} |
1 | 1 |
/* -*- C++ -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2008 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_TEST_GRAPH_TEST_H |
20 | 20 |
#define LEMON_TEST_GRAPH_TEST_H |
21 | 21 |
|
22 | 22 |
//#include <lemon/graph_utils.h> |
23 | 23 |
#include "test_tools.h" |
24 | 24 |
|
25 | 25 |
//! \ingroup misc |
26 | 26 |
//! \file |
27 | 27 |
//! \brief Some utility and test cases to test digraph classes. |
28 | 28 |
namespace lemon { |
29 | 29 |
|
30 | 30 |
///Structure returned by \ref addPetersen(). |
31 | 31 |
|
32 | 32 |
///Structure returned by \ref addPetersen(). |
33 | 33 |
/// |
34 | 34 |
template<class Digraph> |
35 | 35 |
struct PetStruct |
36 | 36 |
{ |
37 | 37 |
///Vector containing the outer nodes. |
38 | 38 |
std::vector<typename Digraph::Node> outer; |
39 | 39 |
///Vector containing the inner nodes. |
40 | 40 |
std::vector<typename Digraph::Node> inner; |
41 | 41 |
///Vector containing the edges of the inner circle. |
42 | 42 |
std::vector<typename Digraph::Arc> incir; |
43 | 43 |
///Vector containing the edges of the outer circle. |
44 | 44 |
std::vector<typename Digraph::Arc> outcir; |
45 | 45 |
///Vector containing the chord edges. |
46 | 46 |
std::vector<typename Digraph::Arc> chords; |
47 | 47 |
}; |
48 | 48 |
|
49 | 49 |
|
50 | 50 |
|
51 | 51 |
///Adds a Petersen graph to \c G. |
52 | 52 |
|
53 | 53 |
///Adds a Petersen graph to \c G. |
1 | 1 |
/* -*- C++ -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2008 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#include <lemon/concepts/graph.h> |
20 | 20 |
#include <lemon/list_graph.h> |
21 | 21 |
// #include <lemon/smart_graph.h> |
22 | 22 |
// #include <lemon/full_graph.h> |
23 | 23 |
// #include <lemon/grid_graph.h> |
24 | 24 |
|
25 | 25 |
//#include <lemon/graph_utils.h> |
26 | 26 |
|
27 | 27 |
#include "test_tools.h" |
28 | 28 |
|
29 | 29 |
|
30 | 30 |
using namespace lemon; |
31 | 31 |
using namespace lemon::concepts; |
32 | 32 |
|
33 | 33 |
void check_concepts() { |
34 | 34 |
|
35 | 35 |
{ // checking digraph components |
36 | 36 |
checkConcept<BaseGraphComponent, BaseGraphComponent >(); |
37 | 37 |
|
38 | 38 |
checkConcept<IDableGraphComponent<>, |
39 | 39 |
IDableGraphComponent<> >(); |
40 | 40 |
|
41 | 41 |
checkConcept<IterableGraphComponent<>, |
42 | 42 |
IterableGraphComponent<> >(); |
43 | 43 |
|
44 | 44 |
checkConcept<MappableGraphComponent<>, |
45 | 45 |
MappableGraphComponent<> >(); |
46 | 46 |
|
47 | 47 |
} |
48 | 48 |
{ |
49 | 49 |
checkConcept<Graph, ListGraph>(); |
50 | 50 |
// checkConcept<Graph, SmartGraph>(); |
51 | 51 |
// checkConcept<Graph, FullGraph>(); |
52 | 52 |
// checkConcept<Graph, Graph>(); |
53 | 53 |
// checkConcept<Graph, GridGraph>(); |
1 | 1 |
/* -*- C++ -*- |
2 | 2 |
* |
3 | 3 |
* This file is a part of LEMON, a generic C++ optimization library |
4 | 4 |
* |
5 |
* Copyright (C) 2003- |
|
5 |
* Copyright (C) 2003-2008 |
|
6 | 6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
7 | 7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
8 | 8 |
* |
9 | 9 |
* Permission to use, modify and distribute this software is granted |
10 | 10 |
* provided that this copyright notice appears in all copies. For |
11 | 11 |
* precise terms see the accompanying LICENSE file. |
12 | 12 |
* |
13 | 13 |
* This software is provided "AS IS" with no warranty of any kind, |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_TEST_MAP_TEST_H |
20 | 20 |
#define LEMON_TEST_MAP_TEST_H |
21 | 21 |
|
22 | 22 |
|
23 | 23 |
#include <vector> |
24 | 24 |
#include <lemon/maps.h> |
25 | 25 |
|
26 | 26 |
#include "test_tools.h" |
27 | 27 |
|
28 | 28 |
|
29 | 29 |
//! \ingroup misc |
30 | 30 |
//! \file |
31 | 31 |
//! \brief Some utilities to test map classes. |
32 | 32 |
|
33 | 33 |
namespace lemon { |
34 | 34 |
|
35 | 35 |
|
36 | 36 |
|
37 | 37 |
template <typename Graph> |
38 | 38 |
void checkGraphNodeMap() { |
39 | 39 |
Graph graph; |
40 | 40 |
const int num = 16; |
41 | 41 |
|
42 | 42 |
typedef typename Graph::Node Node; |
43 | 43 |
|
44 | 44 |
std::vector<Node> nodes; |
45 | 45 |
for (int i = 0; i < num; ++i) { |
46 | 46 |
nodes.push_back(graph.addNode()); |
47 | 47 |
} |
48 | 48 |
typedef typename Graph::template NodeMap<int> IntNodeMap; |
49 | 49 |
IntNodeMap map(graph, 42); |
50 | 50 |
for (int i = 0; i < int(nodes.size()); ++i) { |
51 | 51 |
check(map[nodes[i]] == 42, "Wrong map constructor."); |
52 | 52 |
} |
53 | 53 |
for (int i = 0; i < num; ++i) { |
0 comments (0 inline)