forked from jegonzal/PowerGraph
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdcsc_test.cpp
More file actions
61 lines (49 loc) · 1.46 KB
/
dcsc_test.cpp
File metadata and controls
61 lines (49 loc) · 1.46 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
#include <iostream>
#include <vector>
#include <cassert>
#include <graphlab/graph/dcsc_store.hpp>
#include <graphlab/macros_def.hpp>
using namespace graphlab;
int main(int argc, char** argv) {
dcsc_store<uint32_t> store;
std::cout << store;
// basic tests
store.insert(1, 2, 1);
store.insert(2, 5, 2);
store.insert(4, 4, 3);
store.insert(4, 5, 4);
store.insert(0, 1, 5);
store.insert(0, 5, 6);
store.insert(0, 3, 7);
store.insert(3, 3, 8);
store.insert(4, 3, 9);
std::cout << store;
std::cout << "\n\nPrinting column 0\n";
typedef dcsc_store<uint32_t>::entry_type entry_type;
foreach(const entry_type e, store.get_column(0)) {
std::cout << "(" << e.row() << ", " << e.column() << ") = " << e.value() << "\n";
}
std::cout << "\n\nPrinting column 5\n";
foreach(entry_type e, store.get_column(5)) {
std::cout << "(" << e.row() << ", " << e.column() << ") = " << e.value() << "\n";
}
std::cout << "\n\nChanging column 3 to all 1s\n";
foreach(entry_type e, store.get_column(3)) {
e.value() = 1;
}
std::cout << store;
srand(10);
store.clear();
std::vector<uint32_t> row, col, val;
for (size_t i = 0;i < 10000; ++i) {
row.push_back(rand());
col.push_back(rand());
val.push_back(rand());
}
store.construct(row.begin(), row.end(),
col.begin(), col.end(),
val.begin(), val.end());
for (size_t i = 0;i < 10000; ++i) {
assert(store.find(row[i], col[i]) == val[i]);
}
}