"vscode:/vscode.git/clone" did not exist on "9a0e13ac6121c342ed0d67a7474e579ef85f2ef1"
Unverified Commit 27e0e547 authored by Quan (Andy) Gan's avatar Quan (Andy) Gan Committed by GitHub
Browse files

[BUG] Graceful handling of random walking with no successors (#433)

parent d3c24cc2
......@@ -504,12 +504,9 @@ IdArray SamplerOp::RandomWalk(
DLContext{kDLCPU, 0});
dgl_id_t *trace_data = static_cast<dgl_id_t *>(traces->data);
#pragma omp parallel
{
// get per-thread seed
unsigned int random_seed = time(nullptr) ^ omp_get_thread_num();
// FIXME: does OpenMP work with exceptions? Especially without throwing SIGABRT?
unsigned int random_seed = time(nullptr);
#pragma omp for
for (int i = 0; i < num_nodes; ++i) {
const dgl_id_t seed_id = seed_ids[i];
......@@ -523,8 +520,11 @@ IdArray SamplerOp::RandomWalk(
const auto succ = gptr->SuccVec(cur);
const size_t size = succ.size();
cur = succ[rand_r(&random_seed) % size];
if (size == 0) {
LOG(FATAL) << "no successors from vertex " << cur;
return traces;
}
cur = succ[rand_r(&random_seed) % size];
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment