-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathgraph_representation.cpp
More file actions
30 lines (24 loc) · 947 Bytes
/
graph_representation.cpp
File metadata and controls
30 lines (24 loc) · 947 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
using namespace std;
#include "graph_representation.hpp"
#include <iostream>
#include <algorithm>
template <> // TODO: I dunno why I can't do a generic one for key_for_vertexName. It seems I have to specialize it for Int
long int bloomGraph<int>::key_for_vertexName(int v) const {
// Don't use this function until populateVerticesAndCountDegree and populateHash is complete.
if(!hash_offsets.empty()) {
unsigned int h = hash_integer<unsigned int>(v, hash_offsets.size());
for(unsigned int j = 0; j<5 && h+j < hash_offsets.size() ; j++) {
unsigned int k = hash_offsets.at(h+j);
assert(k < vertex_mappings.size());
if(vertex_mappings.at(k) == v) {
return k;
}
}
}
const int * lb = &(*lower_bound(vertex_mappings.begin(),vertex_mappings.begin()+vcount(),v));
const int * begin = &(*vertex_mappings.begin());
return lb - begin;
}
string VertexNameToString (const int &l) {
ostringstream s; s << l; return s.str();
}