Re-use EdgeIterator

39 views Asked by At

If I understand well, an EdgeIterator can be used only one time. If this is correct, why can't we simply reset it to avoid creating a new instance of EdgeIterator each time we need to loop over the same node edges ?

Thanks !

1

There are 1 answers

1
Karussell On BEST ANSWER

The EdgeIterator is reused if you use the EdgeExplorer:

// store somewhere
explorer = graph.createEdgeExplorer();

// use somewhere
EdgeIterator iter = explorer.setBaseNode(x);
while(iter) {..}

Still be very careful with this as you need one edgeExplorer for every thread and every loop e.g. having a double for-loop with one explorer will fail :)