hiperwalk.IntegerLattice#
- hiperwalk.IntegerLattice(dim, basis=None, periodic=True, multiedges=None, weights=None, copy=False)[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.
basiscan be specified in three different ways. Letn = len(dim).NoneEquivalent to the argument
[1, ..., n].
- list of int
Adjacency is described by the standard basis where
icorresponds to the array with all entries equal to0and thei-1-th entry equal to1. Analogously,-icorresponds to the same array but in the opposite direction (-1instead of1).The values of
basismust satisfy1 <= abs(basis) <= n. Note that 0 is not a valid value because-0 == 0.It is expected that
len(basis) == 2*norlen(basis) == n. Iflen(basis) == n, the equivalent argument is[basis[0], ..., basis[n - 1], -basis[0], ..., -basis[n - 1]]
- matrix
A matrix with
2*nrows andncolumns. 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
Trueif the grid has cyclic boundary conditions,Falseif it has borders.- multiedges, weights: scipy.sparse.csr_array, default=None
See Graph Constructors.
- copybool, default=False
See Graph Constructors.
- Returns:
hiperwalk.GraphSee 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. |