Skip to contents

make_lattice() is a flexible function, it can create lattices of arbitrary dimensions, periodic or aperiodic ones. It has two forms. In the first form you only supply dimvector, but not length and dim. In the second form you omit dimvector and supply length and dim.

Usage

make_lattice(
  dimvector = NULL,
  length = NULL,
  dim = NULL,
  nei = 1,
  directed = FALSE,
  mutual = FALSE,
  periodic = FALSE,
  circular = deprecated()
)

lattice(...)

Arguments

dimvector

A vector giving the size of the lattice in each dimension.

length

Integer constant, for regular lattices, the size of the lattice in each dimension.

dim

Integer constant, the dimension of the lattice.

nei

The distance within which (inclusive) the neighbors on the lattice will be connected. This parameter is not used right now.

directed

Whether to create a directed lattice.

mutual

Logical, if TRUE directed lattices will be mutually connected.

periodic

Logical vector, Boolean vector, defines whether the generated lattice is periodic along each dimension. This parameter may also be scalar boolen value which will be extended to boolean vector with dimvector length.

circular

Deprecated, use periodic instead.

...

Passed to make_lattice().

Value

An igraph graph.

igraph_square_lattice().

Examples

make_lattice(c(5, 5, 5))
#> IGRAPH 7157df9 U--- 125 300 -- Lattice graph
#> + attr: name (g/c), dimvector (g/n), nei (g/n), mutual (g/l), circular
#> | (g/l)
#> + edges from 7157df9:
#>  [1]  1-- 2  1-- 6  1--26  2-- 3  2-- 7  2--27  3-- 4  3-- 8  3--28  4-- 5
#> [11]  4-- 9  4--29  5--10  5--30  6-- 7  6--11  6--31  7-- 8  7--12  7--32
#> [21]  8-- 9  8--13  8--33  9--10  9--14  9--34 10--15 10--35 11--12 11--16
#> [31] 11--36 12--13 12--17 12--37 13--14 13--18 13--38 14--15 14--19 14--39
#> [41] 15--20 15--40 16--17 16--21 16--41 17--18 17--22 17--42 18--19 18--23
#> [51] 18--43 19--20 19--24 19--44 20--25 20--45 21--22 21--46 22--23 22--47
#> [61] 23--24 23--48 24--25 24--49 25--50 26--27 26--31 26--51 27--28 27--32
#> + ... omitted several edges
make_lattice(length = 5, dim = 3)
#> IGRAPH 6a134d4 U--- 125 300 -- Lattice graph
#> + attr: name (g/c), dimvector (g/n), nei (g/n), mutual (g/l), circular
#> | (g/l)
#> + edges from 6a134d4:
#>  [1]  1-- 2  1-- 6  1--26  2-- 3  2-- 7  2--27  3-- 4  3-- 8  3--28  4-- 5
#> [11]  4-- 9  4--29  5--10  5--30  6-- 7  6--11  6--31  7-- 8  7--12  7--32
#> [21]  8-- 9  8--13  8--33  9--10  9--14  9--34 10--15 10--35 11--12 11--16
#> [31] 11--36 12--13 12--17 12--37 13--14 13--18 13--38 14--15 14--19 14--39
#> [41] 15--20 15--40 16--17 16--21 16--41 17--18 17--22 17--42 18--19 18--23
#> [51] 18--43 19--20 19--24 19--44 20--25 20--45 21--22 21--46 22--23 22--47
#> [61] 23--24 23--48 24--25 24--49 25--50 26--27 26--31 26--51 27--28 27--32
#> + ... omitted several edges