alpar@906
|
1 |
/* -*- C++ -*-
|
alpar@906
|
2 |
*
|
alpar@1956
|
3 |
* This file is a part of LEMON, a generic C++ optimization library
|
alpar@1956
|
4 |
*
|
alpar@1956
|
5 |
* Copyright (C) 2003-2006
|
alpar@1956
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
|
alpar@1359
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES).
|
alpar@906
|
8 |
*
|
alpar@906
|
9 |
* Permission to use, modify and distribute this software is granted
|
alpar@906
|
10 |
* provided that this copyright notice appears in all copies. For
|
alpar@906
|
11 |
* precise terms see the accompanying LICENSE file.
|
alpar@906
|
12 |
*
|
alpar@906
|
13 |
* This software is provided "AS IS" with no warranty of any kind,
|
alpar@906
|
14 |
* express or implied, and with no claim as to its suitability for any
|
alpar@906
|
15 |
* purpose.
|
alpar@906
|
16 |
*
|
alpar@906
|
17 |
*/
|
alpar@906
|
18 |
|
hegyi@820
|
19 |
#include <string>
|
hegyi@820
|
20 |
#include <iostream>
|
deba@2247
|
21 |
|
klao@959
|
22 |
#include <lemon/concept/path.h>
|
deba@2247
|
23 |
#include <lemon/concept/graph.h>
|
deba@2247
|
24 |
|
alpar@921
|
25 |
#include <lemon/path.h>
|
alpar@921
|
26 |
#include <lemon/list_graph.h>
|
hegyi@820
|
27 |
|
deba@2247
|
28 |
#include "test_tools.h"
|
deba@2247
|
29 |
|
hegyi@820
|
30 |
using namespace std;
|
alpar@921
|
31 |
using namespace lemon;
|
hegyi@820
|
32 |
|
deba@2247
|
33 |
void check_concepts() {
|
deba@2247
|
34 |
checkConcept<concept::Path<concept::Graph>,
|
deba@2247
|
35 |
concept::Path<concept::Graph> >();
|
deba@2247
|
36 |
checkConcept<concept::Path<concept::Graph>,
|
deba@2247
|
37 |
Path<concept::Graph> >();
|
deba@2247
|
38 |
checkConcept<concept::Path<ListGraph>, Path<ListGraph> >();
|
hegyi@820
|
39 |
}
|
hegyi@820
|
40 |
|
deba@2247
|
41 |
int main() {
|
deba@2247
|
42 |
check_concepts();
|
deba@2247
|
43 |
|
deba@2247
|
44 |
ListGraph g;
|
deba@2247
|
45 |
|
deba@2247
|
46 |
ListGraph::Node n1 = g.addNode();
|
deba@2247
|
47 |
ListGraph::Node n2 = g.addNode();
|
deba@2247
|
48 |
ListGraph::Node n3 = g.addNode();
|
deba@2247
|
49 |
ListGraph::Node n4 = g.addNode();
|
deba@2247
|
50 |
ListGraph::Node n5 = g.addNode();
|
deba@2247
|
51 |
|
deba@2247
|
52 |
ListGraph::Edge e1 = g.addEdge(n1, n2);
|
deba@2247
|
53 |
ListGraph::Edge e2 = g.addEdge(n2, n3);
|
deba@2247
|
54 |
ListGraph::Edge e3 = g.addEdge(n3, n4);
|
deba@2247
|
55 |
ListGraph::Edge e4 = g.addEdge(n4, n5);
|
deba@2247
|
56 |
ListGraph::Edge e5 = g.addEdge(n5, n1);
|
hegyi@820
|
57 |
|
deba@2247
|
58 |
{
|
deba@2247
|
59 |
Path<ListGraph> p(g);
|
deba@2247
|
60 |
|
deba@2247
|
61 |
check(p.empty(), "Wrong Path");
|
deba@2247
|
62 |
check(p.length() == 0, "Wrong Path");
|
deba@2247
|
63 |
|
deba@2247
|
64 |
{
|
deba@2247
|
65 |
Path<ListGraph>::Builder b(p);
|
deba@2247
|
66 |
b.setStartNode(n3);
|
deba@2247
|
67 |
b.commit();
|
deba@2247
|
68 |
}
|
deba@2247
|
69 |
|
deba@2247
|
70 |
check(!p.empty(), "Wrong Path");
|
deba@2247
|
71 |
check(p.length() == 0, "Wrong Path");
|
deba@2247
|
72 |
check(p.source() == n3, "Wrong Path");
|
deba@2247
|
73 |
check(p.target() == n3, "Wrong Path");
|
deba@2247
|
74 |
|
deba@2247
|
75 |
{
|
deba@2247
|
76 |
Path<ListGraph>::Builder b(p);
|
deba@2247
|
77 |
b.pushBack(e3);
|
deba@2247
|
78 |
b.pushBack(e4);
|
deba@2247
|
79 |
b.pushFront(e2);
|
deba@2247
|
80 |
b.commit();
|
deba@2247
|
81 |
}
|
deba@2247
|
82 |
|
deba@2247
|
83 |
check(!p.empty(), "Wrong Path");
|
deba@2247
|
84 |
check(p.length() == 3, "Wrong Path");
|
deba@2247
|
85 |
check(p.source() == n2, "Wrong Path");
|
deba@2247
|
86 |
check(p.target() == n5, "Wrong Path");
|
deba@2247
|
87 |
|
deba@2247
|
88 |
{
|
deba@2247
|
89 |
Path<ListGraph>::NodeIt it(p);
|
deba@2247
|
90 |
check((ListGraph::Node)it == n2, "Wrong Path"); ++it;
|
deba@2247
|
91 |
check((ListGraph::Node)it == n3, "Wrong Path"); ++it;
|
deba@2247
|
92 |
check((ListGraph::Node)it == n4, "Wrong Path"); ++it;
|
deba@2247
|
93 |
check((ListGraph::Node)it == n5, "Wrong Path"); ++it;
|
deba@2247
|
94 |
check((ListGraph::Node)it == INVALID, "Wrong Path");
|
deba@2247
|
95 |
}
|
deba@2247
|
96 |
|
deba@2247
|
97 |
{
|
deba@2247
|
98 |
Path<ListGraph>::EdgeIt it(p);
|
deba@2247
|
99 |
check((ListGraph::Edge)it == e2, "Wrong Path"); ++it;
|
deba@2247
|
100 |
check((ListGraph::Edge)it == e3, "Wrong Path"); ++it;
|
deba@2247
|
101 |
check((ListGraph::Edge)it == e4, "Wrong Path"); ++it;
|
deba@2247
|
102 |
check((ListGraph::Edge)it == INVALID, "Wrong Path");
|
deba@2247
|
103 |
}
|
deba@2247
|
104 |
|
deba@2247
|
105 |
}
|
deba@2247
|
106 |
|
deba@2247
|
107 |
return 0;
|
hegyi@820
|
108 |
}
|