Add support for k-nearest neighbor edges in `Lattice`
Created by: femtobit
This PR adds support for adding edges beyond nearest neighbors to Lattice
. The edges are distinguished by color, i.e., an edge between k-th nearest neighbors has color k.
For example, this
>>> g = Square(4, max_neighbor_order=2, pbc=False)
>>> g.draw()
gives you the following lattice: and the edges are colored by k:
>>> g.edges(return_color=True)
[(0, 1, 0),
(0, 4, 0),
(1, 2, 0),
...
(0, 5, 1),
(1, 4, 1),
(1, 6, 1),
...
(11, 14, 1)]
The benefit of this method is that it makes it very easy to use GraphOperator
to implement different couplings depending on the distance. If separate graphs for the different distances are needed, this can be done by extracting the edges:
>>> # next nearest neighbor graph
>>> g_nnn = Graph(edges=g.edges(filter_color=1))
This should work correctly with and without PBC. I can add some tests if everyone agrees with the general design.