[Networkit] Weird bug: forEdgesOf iterates wrong edged

Lukas Barth lists at tinloaf.de
Mon Dec 1 12:03:44 CET 2014


Hi everyone,

I'm currently trying to use NetworKit for a university project, and I'm
experiencing a strange bug I cannot explain. This is my (abbreviated) code:

=========
... walkToTransit(node prevNode, node curNode) const {
	if (this->G.degree(curNode) > 2) {
		return {curNode, 0};
	}

	std::cout << "Walking on " << curNode << "\n";
	std::cout << "degree: " << this->G.degree(curNode) << "\n";

	Transit next;
	int nextDist = std::numeric_limits<int>::max();

	G.forEdgesOf(curNode, [&](node cur, node v, double weight) {
		std::cout << "Next node: " << v << " from " << cur << "\n";
		if (v != prevNode) {
			assert(nextDist == std::numeric_limits<int>::max());
			next = this->walkToTransit(curNode, v);
			nextDist = (int)weight;
		}
	});

	[...]
=========

Now, that gives me this output:

=========
[...]
Walking on 93573
degree: 2
Next node: 119538 from 93573
Next node: 46333 from 93573
Next node: 105480 from 46333
Next node: 14505 from 105480
hl: src/HubLabeling.h:129:
HubLabeling<HubLabels>::walkToTransit(NetworKit::node, NetworKit::node)
const [with HubLabels = DynamicHubLabels; Transit = transit_st;
NetworKit::node = long unsigned int]::__lambda6: Assertion `nextDist ==
std::numeric_limits<int>::max()' failed.
=========

How can that be? I'm iterating the edges of node #93573 (curNode), so in
the handle, "cur" should always be 93573. Yet, after the first two edges
(which are all the edges that node should have, see the degree), I keep
getting edges of adjacent vertices...?

I checked: Using forNeighborsOf() gives me the same results.

Did anyone ever see something like this? Any ideas where this comes from?

Kind regards,

Lukas Barth



More information about the NetworKit mailing list