I write a graph to a simple text file format (adjacency list). In one instance, I discovered that the resulting file contains a strange very long line of "NUL" characters.
Where might these null characters come from? What do they mean?
The code that produces the file is
void GraphIO::writeAdjacencyList(Graph& G, std::string path) {
std::ofstream file;
file.open(path.c_str());
G.forallNodes([&](node v) {
file << v;
G.forallNeighborsOf(v, [&](node x) {
file << " " << x;
});
file << std::endl;
});
INFO("wrote graph to file: " << path);
}
Iteration over all nodes is realized as:
template<typename Callback>
inline void EnsembleClustering::Graph::forallNodes(Callback func, std::string par) {
assert ((par == "") || (par == "parallel"));
int64_t n = this->numberOfNodes();
#pragma omp parallel for if (par == "parallel")
for (node v = this->firstNode(); v <= n; ++v) {
// call node function
func(v);
}
}
EDIT: the type node
is simply a typedef for int64_t