-
Notifications
You must be signed in to change notification settings - Fork 21
Expand file tree
/
Copy pathtest_ascii_graph.cpp
More file actions
129 lines (91 loc) · 3.99 KB
/
Copy pathtest_ascii_graph.cpp
File metadata and controls
129 lines (91 loc) · 3.99 KB
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
/*
* Portions copyright (c) 2003-2007, Paolo Boldi and Sebastiano Vigna. Translation copyright (c) 2007, Jacob Ratkiewicz
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the Free
* Software Foundation; either version 2 of the License, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
*/
#include "../offline_graph.hpp"
#include <iostream>
#include <utility>
#include <boost/tuple/tuple.hpp>
#include <iterator>
#include <algorithm>
#include <boost/shared_ptr.hpp>
using namespace std;
using namespace webgraph::ascii_graph;
using namespace boost;
void print_all_vertices_and_edges( offline_graph_ptr oag );
void print_first_n_edges( offline_graph_ptr oag, int n );
////////////////////////////////////////////////////////////////////////////////
int main( int argc, char* argv[] ) {
cerr << "Started.\n";
if( argc < 2 ) {
cerr << "Usage is " << argv[0] << " [graph-basename]" << endl;
return 1;
}
offline_graph o = offline_graph::load( argv[1] );
// print_first_n_edges( oag, 10 );
print_all_vertices_and_edges( o );
return 0;
}
////////////////////////////////////////////////////////////////////////////////
void print_first_n_edges( offline_graph o, int n ) {
offline_graph::edge_iterator begin, end;
tie( begin, end ) = o.get_edge_iterator();
cerr << "About to start printing first " << n << " edges.\n";
int i = 0;
for( offline_graph::edge_iterator iter = begin;
iter != end && i < n;
iter++, i++ ) {
offline_graph::edge_type next_edge;
next_edge = *iter;
cerr << "<" << next_edge.first << ", " << next_edge.second << ">";
}
cerr << "Done.\n";
}
////////////////////////////////////////////////////////////////////////////////
void print_all_vertices_and_edges( offline_graph_ptr oag ) {
offline_graph::vertex_iterator begin, end;
// cerr << "This is what they look like, straight out of th graph.\n";
// cerr << o.get_vertex_iterator().first.as_str() << endl;
// cerr << o.get_vertex_iterator().second.as_str() << endl;
// cerr << "Now tie them, and see what they look like afterwards.\n";
tie( begin, end ) = o.get_vertex_iterator();
// cerr << "Begin is " << begin.as_str();
// cerr << " and end is " << end.as_str() << endl;
int i = 0;
cerr << "Vertices are: " << endl;
for( offline_graph::vertex_iterator iter = begin;
iter != end;
++iter ) {
cerr << *iter << ": ";
ostream_iterator<int> meh( cerr, " " );
copy( successors(iter).begin(), successors(iter).end(), meh );
cerr << endl;
}
cerr << "\n**************************************\n";
cerr << "Now iterating over all edges. Here goes...\n";
offline_graph::edge_iterator e_begin, e_end;
tie( e_begin, e_end ) = o.get_edge_iterator();
cerr << "Got edge iterator.\n";
i = 0;
for( offline_graph::edge_iterator iter = e_begin;
iter != e_end;
iter++) {
offline_graph::edge_type edge = *iter;
cerr << "<" << edge.first << ", " << edge.second << ">\n";
}
cerr << "Done." << endl;
}