Location: LEMON/LEMON-main/test/euler_test.cc - annotation
Load file history
Use XTI implementation instead of ATI in NetworkSimplex (#234)
XTI (eXtended Threaded Index) is an imporved version of the widely
known ATI (Augmented Threaded Index) method for storing and updating
the spanning tree structure in Network Simplex algorithms.
In the ATI data structure three indices are stored for each node:
predecessor, thread and depth. In the XTI data structure depth is
replaced by the number of successors and the last successor
(according to the thread index).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 | r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r531:ba7bafdc458d r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r531:ba7bafdc458d r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r531:ba7bafdc458d r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r531:ba7bafdc458d r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 r522:22f932bbb305 | /* -*- mode: C++; indent-tabs-mode: nil; -*-
*
* This file is a part of LEMON, a generic C++ optimization library.
*
* Copyright (C) 2003-2009
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
* (Egervary Research Group on Combinatorial Optimization, EGRES).
*
* Permission to use, modify and distribute this software is granted
* provided that this copyright notice appears in all copies. For
* precise terms see the accompanying LICENSE file.
*
* This software is provided "AS IS" with no warranty of any kind,
* express or implied, and with no claim as to its suitability for any
* purpose.
*
*/
#include <lemon/euler.h>
#include <lemon/list_graph.h>
#include <test/test_tools.h>
using namespace lemon;
template <typename Digraph>
void checkDiEulerIt(const Digraph& g)
{
typename Digraph::template ArcMap<int> visitationNumber(g, 0);
DiEulerIt<Digraph> e(g);
typename Digraph::Node firstNode = g.source(e);
typename Digraph::Node lastNode = g.target(e);
for (; e != INVALID; ++e)
{
if (e != INVALID)
{
lastNode = g.target(e);
}
++visitationNumber[e];
}
check(firstNode == lastNode,
"checkDiEulerIt: first and last node are not the same");
for (typename Digraph::ArcIt a(g); a != INVALID; ++a)
{
check(visitationNumber[a] == 1,
"checkDiEulerIt: not visited or multiple times visited arc found");
}
}
template <typename Graph>
void checkEulerIt(const Graph& g)
{
typename Graph::template EdgeMap<int> visitationNumber(g, 0);
EulerIt<Graph> e(g);
typename Graph::Node firstNode = g.u(e);
typename Graph::Node lastNode = g.v(e);
for (; e != INVALID; ++e)
{
if (e != INVALID)
{
lastNode = g.v(e);
}
++visitationNumber[e];
}
check(firstNode == lastNode,
"checkEulerIt: first and last node are not the same");
for (typename Graph::EdgeIt e(g); e != INVALID; ++e)
{
check(visitationNumber[e] == 1,
"checkEulerIt: not visited or multiple times visited edge found");
}
}
int main()
{
typedef ListDigraph Digraph;
typedef ListGraph Graph;
Digraph digraphWithEulerianCircuit;
{
Digraph& g = digraphWithEulerianCircuit;
Digraph::Node n0 = g.addNode();
Digraph::Node n1 = g.addNode();
Digraph::Node n2 = g.addNode();
g.addArc(n0, n1);
g.addArc(n1, n0);
g.addArc(n1, n2);
g.addArc(n2, n1);
}
Digraph digraphWithoutEulerianCircuit;
{
Digraph& g = digraphWithoutEulerianCircuit;
Digraph::Node n0 = g.addNode();
Digraph::Node n1 = g.addNode();
Digraph::Node n2 = g.addNode();
g.addArc(n0, n1);
g.addArc(n1, n0);
g.addArc(n1, n2);
}
Graph graphWithEulerianCircuit;
{
Graph& g = graphWithEulerianCircuit;
Graph::Node n0 = g.addNode();
Graph::Node n1 = g.addNode();
Graph::Node n2 = g.addNode();
g.addEdge(n0, n1);
g.addEdge(n1, n2);
g.addEdge(n2, n0);
}
Graph graphWithoutEulerianCircuit;
{
Graph& g = graphWithoutEulerianCircuit;
Graph::Node n0 = g.addNode();
Graph::Node n1 = g.addNode();
Graph::Node n2 = g.addNode();
g.addEdge(n0, n1);
g.addEdge(n1, n2);
}
checkDiEulerIt(digraphWithEulerianCircuit);
checkEulerIt(graphWithEulerianCircuit);
check(eulerian(digraphWithEulerianCircuit),
"this graph should have an Eulerian circuit");
check(!eulerian(digraphWithoutEulerianCircuit),
"this graph should not have an Eulerian circuit");
check(eulerian(graphWithEulerianCircuit),
"this graph should have an Eulerian circuit");
check(!eulerian(graphWithoutEulerianCircuit),
"this graph should have an Eulerian circuit");
return 0;
}
|