Simplify graph code in conv layer
Created by: femtobit
As far as I understand, the following part of the code in the Convolutional
class is supposed to store, for each node i
, all nodes with distance of at most dist_
to i
in neighbours_[i]
:
https://github.com/netket/netket/blob/67fe7e62c93abf4280d85c16023563868b3e41bd/NetKet/Machine/conv_layer.hpp#L115-L137
I found the logic there a bit hard to read an rewrote it in terms of a breadth-first search started from each node, which I find easier to understand. (It could also be a bit faster, but I did not check this.) The BFS code can potentially also be useful elsewhere.
If this looks good to you, accepting this PR will merge the changes into the branch for the feedforward PR #46 (so this is a PR on a PR, essentially).