# Generating a lattice by $𝑁^{𝑡ℎ}$ iteration of unit cell

This question is in continuation of the my previous question that was not clearly presented by me at all.

I have a unit cell, and I would like to generate a lattice but in iterative order. For instance, consider the following example--

1. First, we generate the lattice, where the lattice points are shown by dark spots and dashed lines showing how they are connected (this is an Adjacency graph of the unit cell, so to say). The labelling of the unit cell is shown with $$1_1$$, that means it is the first unit cell and the subscript tells that it is the first generation or iteration. This number $$1_1$$ is just for illustration, nothing more.

1. Then on doing second iteration, that means connecting the unit cell at the six pair of points shown with the dashed orange lines, generates the second iteration (red colored, in total 6, numbered for illustration) that contains $$12\times 6 = 72$$ points (shown with dark red spots) $$+$$ 12 points from first iteration, so in total $$84$$ points. Below is again the illustration of the lattice by the adjacency matrix of the second iteration.

Is there a way to generate the matrix whose adjacency graph at iteration 1 is the first figure and iteration 2 is the second figure?

My MWE:

nthIteration = 1; (* The nth iteration *)

p = 6; (* The number of atoms inside the unit cell without outgoing (or protruding)

Nunitc = (nthIteration - 1) p +
1;  (* The total number of unitcells at nth iteration *)

qn = 2 Nunitc p;

mIteration = Table[0, {i, 1, qn}, {j, 1, qn}];

For[ nunit = 1, nunit <= Nunitc, nunit++,

For[i = 1, i <= qn, i++,

For[j = 1, j <= qn, j++,
mIteration[[i, j]] =
mIteration[[i, j]] +
If[(Abs[i - j] == p - 1 \[Or]
Abs[i - j] == 1) \[And] (2 (nunit - 1) p <
j <= (2 nunit - 1) p \[And]
2 (nunit - 1) p < i <= (2 nunit - 1) p), 1, 0];
mIteration[[i, j]] =
mIteration[[i, j]] +
If[(2 (nunit - 1) p < i <= 2 nunit p \[And]
2 (nunit - 1) p < j <= 2 nunit p) \[And]
Mod[i + j, 2] == 0 \[And] Abs[i - j] == p, 1, 0];

]

]

]


As can be seen by executing the above code, I can generate the $$N^{th}$$ iteration by iterating the unit cell, but I am not able to connect them at any $$N^{th}$$ iteration (the dashed orange lines shown before for the second iteration), i.e., the only missing piece.
Any help in this direction is of tremendous help.

hex = CirclePoints[{1, Pi/6}, 6];
spikes = CirclePoints[{2, Pi/6}, 6];
core = Join[hex, spikes];

center = NearestNeighborGraph[core, {3, 1 + 10^-2},
DistanceFunction -> (EuclideanDistance @@ N[{##}] &)];

Δ = 1;

firstlayer = Join @@ Table[FullSimplify @
(k RotationTransform[j Pi/3, {0, 0}]@{Δ + 2 Sqrt@ 3, 0} + # & /@ core),
{k, {-1, 1}}, {j, 1, 3}];

ring = NearestNeighborGraph[#, {3, 1 + 10^-2},
DistanceFunction -> (EuclideanDistance @@ N[{##}] &)] & /@ firstlayer;

connectors = Graph @ EdgeList @ RelationGraph[
EuclideanDistance @@ N[{##}] <= Δ + 10^-2 &,
GraphPeriphery[center], Join @@ (GraphPeriphery /@ ring)];

edgeColors =  # /. {Alternatives @@ EdgeList[center] -> Red,
Alternatives @@ EdgeList[connectors] -> Orange, _ -> Gray} &;

g0 = Graph[Flatten[EdgeList /@ Flatten[{center, ring, connectors}]],
VertexCoordinates -> {v_ :> v}, PerformanceGoal -> "Quality",
EdgeStyle -> {e_ :>  Directive[edgeColors @ e, JoinForm["Round"],
CapForm["Round"], AbsoluteThickness[15]]}]


adjmat = AdjacencyMatrix[g0];



With Δ = 2 we get

• Many thanks! This exactly hits the bulls eye :) Just to understand better the nice code, could you say very few words about it for a person ignorant like me (so that I understand the logic behind the connections or links)? Also can we control the size of the inside, subsequently the size of the outer unit cells, for instance, if p=6 it gives your plot if p=3 it gives a triangular lattice with respective links, p=4 square, and so on so forth... Billion thanks
– L.K.
Mar 29 '21 at 9:14
• @L.K., if you use NearestNeihborGraph on the list of coordinates core (with {3,1.} as the second argument to allow up to three neighbors within Euclidean distance 1 for each point) we get a hexagon-with-spikes (your $1_1$). The horizontal width of core is $2 \sqrt 3$. To get the outer ring we translate core horizontally by width + dist, then make 5 additional copies rotating the translated core by 60 degree at each step. Generalizing to an arbitrary regular-n-gon with spikes with arbitrary number of layers would be more involved (maybe you can post it as a new question).
– kglr
Mar 29 '21 at 12:13
• Thanks! This explanation was very helpful. I have a almost a last question. Can we remove the connection between two gray out unit cells? So that triangle like structure is not formed with the orange color? i.e. orange and grey are connected not grey with grey.
– L.K.
Mar 29 '21 at 14:49
• Thank you so much for putting so much effort into this!
– L.K.
Mar 29 '21 at 19:41
• @L.K., my pleasure. Thank you for the accept.
– kglr
Mar 29 '21 at 19:46