I am trying to create an adjacency matrix for square lattice. If denotes a vertex in the lattice then I first index all the nodes in the lattice using a single index such that . After that I want to write adjacency matrix. But I am not able to do it properly. Please help me. Thank you
Easy Math Editor
This discussion board is a place to discuss our Daily Challenges and the math and science related to those challenges. Explanations are more than just a solution — they should explain the steps and thinking strategies that you used to obtain the solution. Comments should further the discussion of math and science.
When posting on Brilliant:
*italics*
or_italics_
**bold**
or__bold__
paragraph 1
paragraph 2
[example link](https://brilliant.org)
> This is a quote
\(
...\)
or\[
...\]
to ensure proper formatting.2 \times 3
2^{34}
a_{i-1}
\frac{2}{3}
\sqrt{2}
\sum_{i=1}^3
\sin \theta
\boxed{123}
Comments
You move between adjacent vertices in the same row by adding or subtracting 1, and you move between adjacent vertices in the same column by adding or subtracting n. Thus vertex k is adjacent to:
Vertex k+1, unless n divides k,
Vertex k−1, unless n divides k−1,
Vertex k+n, unless k+n>n2,
Vertex k−n, unless k−n≤0.
Adjacency matrices for 2×2 and 3×3 grids are ⎝⎜⎜⎛0110100110010110⎠⎟⎟⎞⎝⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎜⎛010100000101010000010001000100010100010101010001010001000100010000010101000001010⎠⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎟⎞
Log in to reply
Thank you. This really looks cool.. I will modify my code now. I was mainly having problem at edges but now I got your idea of checking whether n divides those indices or not. I will get back to you soon.
Yess.. I modified my code and it works perfectly now!! Thank you very much sir!