hiperwalk.IntegerLattice#
- hiperwalk.IntegerLattice(dim, basis=None, periodic=True, multiedges=None, weights=None)[source]#
Integer lattice graph.
An integer lattice is a lattice in an euclidean space such that every point is a tuple of integers. In the integer lattice graph, every vertex corresponds to a lattice point.
- Parameters:
- dimtuple of int
Lattice dimensions where
dim[i]
is the number of vertices in thei
-th-axis.- basislist of int or matrix, default=None
Vectors used to determine the graph adjacency and the corresponding order of neighbors.
basis
can be specified in three different ways. Letn = len(dim)
.None
Equivalent to the argument
[1, ..., n]
.
- list of int
Adjacency is described by the standard basis where
i
corresponds to the array with all entries equal to0
and thei-1
-th entry equal to1
. Analogously,-i
corresponds to the same array but in the opposite direction (-1
instead of1
).The values of
basis
must satisfy1 <= abs(basis) <= n
. Note that 0 is not a valid value because-0 == 0
.It is expected that
len(basis) == 2*n
orlen(basis) == n
. Iflen(basis) == n
, the equivalent argument is[basis[0], ..., basis[n - 1], -basis[0], ..., -basis[n - 1]]
- matrix
A matrix with
2*n
rows andn
columns. Thei
-th neighbor of the vertex with coordinates(v[0], ..., v[n-1])
is(v[0] + basis[i][0], ..., v[n-1] + basis[i][n-1])
.
- periodicbool, default=True
True
if the grid has cyclic boundary conditions,False
if it has borders.- multiedges, weights: scipy.sparse.csr_array, default=None
See Graph Constructors.
- Returns:
hiperwalk.Graph
See Graph Constructors for details.
See also
Notes
The order of neighbors depends on the value of
basis
.The vertex number depends on its coordinates and
dim
. If the coordinates of a vertex are(v[0], ..., v[n-1])
, its number isv[n-1] + dim[n-1]*v[n-2] + ... + dim[n-1]*...*dim[1]*v[0]
.Examples
>>> g = hpw.IntegerLattice((3, 3), basis=None) >>> neigh = g.neighbors((1, 1)) >>> [tuple(g.vertex_coordinates(v)) for v in neigh] [(2, 1), (1, 2), (0, 1), (1, 0)]
>>> g = hpw.IntegerLattice((3, 3), basis=[-1, -2]) >>> neigh = g.neighbors((1, 1)) >>> [tuple(g.vertex_coordinates(v)) for v in neigh] [(0, 1), (1, 0), (2, 1), (1, 2)]
>>> basis = [[0, 1], [-1, 1], [1, -1], [0, -1]] >>> g = hpw.IntegerLattice((3, 3), basis=basis) >>> neigh = g.neighbors((1, 1)) >>> [tuple(g.vertex_coordinates(v)) for v in neigh] [(1, 2), (0, 2), (2, 0), (1, 0)]
Methods#
Besides all methods inherited from
hiperwalk.Graph
,
hiperwalk.Multigraph
,
or hiperwalk.WeightedGraph
,
an integer lattice instance also has the following method.
|
Dimensions of integer lattice. |
|
Return the coordinates of the given vertex. |