-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstance.cc
More file actions
33 lines (30 loc) · 816 Bytes
/
instance.cc
File metadata and controls
33 lines (30 loc) · 816 Bytes
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
#include "instance.h"
instance::instance() {
dim_sizes = std::vector< int >();
nets = std::vector< net >();
}
instance from_stream(std::ifstream& in) {
instance ret;
assert(!in.eof());
in >> ret.num_dims >> ret.num_nets;
ret.dim_sizes = std::vector< int >(ret.num_dims);
ret.nets = std::vector< net >(ret.num_nets);
for(int& x : ret.dim_sizes) {
assert(!in.eof());
in >> x;
}
for(int net = 0; net < ret.num_nets; ++net) {
int num_vertices;
assert(!in.eof());
in >> num_vertices;
ret.nets[net].vertices = std::vector< std::vector< int > >(num_vertices,
std::vector< int >(ret.num_dims));
for(auto& vertex : ret.nets[net].vertices) {
for(auto& component : vertex) {
assert(!in.eof());
in >> component;
}
}
}
return ret;
}