-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbatcher.cpp
More file actions
70 lines (53 loc) · 2.15 KB
/
batcher.cpp
File metadata and controls
70 lines (53 loc) · 2.15 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
#include <catch2/catch_test_macros.hpp>
#include "test_graph.h"
#include <gdsb/batcher.h>
#include <gdsb/graph.h>
#include <gdsb/graph_input.h>
using namespace gdsb;
TEST_CASE("Batcher")
{
WeightedEdges32 edges{ { 0, { 1, 1.f } }, { 0, { 2, 1.f } }, { 0, { 3, 1.f } }, { 1, { 2, 1.f } },
{ 1, { 3, 1.f } }, { 2, { 5, 1.f } }, { 2, { 6, 1.f } } };
CHECK(edges.size() == 7);
SECTION("Unsorted batch")
{
Batcher<WeightedEdges32> batcher(std::begin(edges), std::end(edges), 3);
Batch<WeightedEdges32> batch = batcher.next(1);
CHECK(batch.begin->source == edges[0].source);
CHECK(batch.begin->target.vertex == edges[0].target.vertex);
}
}
TEST_CASE("partition_batch_count, on enzymes graph")
{
std::ifstream binary_graph(graph_path + directed_unweighted_graph_enzymes_bin);
BinaryGraphHeader header = read_binary_graph_header(binary_graph);
SECTION("partition size 2")
{
uint32_t partition_size = 2;
uint32_t partition_id = 0;
uint64_t edge_count = partition_batch_count(header.edge_count, partition_id, partition_size);
CHECK(edge_count == 84);
partition_id = 1;
edge_count = partition_batch_count(header.edge_count, partition_id, partition_size);
CHECK(edge_count == 84);
}
SECTION("partition size 5")
{
uint32_t partition_size = 5;
uint32_t partition_id = 0;
uint64_t edge_count = partition_batch_count(header.edge_count, partition_id, partition_size);
CHECK(edge_count == 33);
partition_id = 1;
edge_count = partition_batch_count(header.edge_count, partition_id, partition_size);
CHECK(edge_count == 33);
partition_id = 2;
edge_count = partition_batch_count(header.edge_count, partition_id, partition_size);
CHECK(edge_count == 33);
partition_id = 3;
edge_count = partition_batch_count(header.edge_count, partition_id, partition_size);
CHECK(edge_count == 33);
partition_id = 4;
edge_count = partition_batch_count(header.edge_count, partition_id, partition_size);
CHECK(edge_count == 36);
}
}