blob: 2f4edf52d665ef4fb24d59c5b3971e43d4f33b8d (
plain)
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
|
/* -*- mode: C++; indent-tabs-mode: nil; -*-
*
* This file is a part of LEMON, a generic C++ optimization library.
*
* Copyright (C) 2003-2013
* 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 <iostream>
#include "lemon/list_graph.h"
#include "lemon/lgf_reader.h"
#include "test_tools.h"
using namespace lemon;
const std::string lgf =
"@nodes\n"
"label\n"
"0\n"
"1\n"
"2\n"
"3\n"
"4\n"
"5\n"
"6\n"
"@arcs\n"
"label\n"
"5 6 0\n"
"5 4 1\n"
"4 6 2\n"
"3 4 3\n"
"3 4 4\n"
"3 2 5\n"
"3 5 6\n"
"3 5 7\n"
"3 5 8\n"
"3 5 9\n"
"2 4 10\n"
"2 4 11\n"
"2 4 12\n"
"2 4 13\n"
"1 2 14\n"
"1 2 15\n"
"1 0 16\n"
"1 3 17\n"
"1 3 18\n"
"1 3 19\n"
"1 3 20\n"
"0 2 21\n"
"0 2 22\n"
"0 2 23\n"
"0 2 24\n";
int main() {
ListDigraph graph;
std::istringstream lgfs(lgf);
DigraphReader<ListDigraph>(graph, lgfs).run();
AllArcLookUp<ListDigraph> lookup(graph);
int numArcs = countArcs(graph);
int arcCnt = 0;
for(ListDigraph::NodeIt n1(graph); n1 != INVALID; ++n1)
for(ListDigraph::NodeIt n2(graph); n2 != INVALID; ++n2)
for(ListDigraph::Arc a = lookup(n1, n2); a != INVALID;
a = lookup(n1, n2, a))
++arcCnt;
check(arcCnt==numArcs, "Wrong total number of arcs");
return 0;
}
|