How to build a neighbor table for the Hexagonal lattice

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
4
down vote

favorite
1












I want to consider a collection of vertices arranged in a finite Hexagonal lattice, with say $n_r$ rows and $n_x$ vertices per row, for a total of $N = n_xn_r$ vertices. The goal is to construct a neighbor table, which is a matrix $A$ with dimensionality $Ntimes N$. Each element $A_ij$ is one if there is a bond connecting vertices $i$ and $j$, and zero otherwise. This can also be seen as an adjacency matrix for a particular graph.



I can't think of a way to build this matrix that isn't frustrating to code as a function of $n_r$ and $n_x$, but I'm aware there are some lattice functions built into Mathematica. Maybe those can make the process more smooth if anyone has suggestions.



Also, to make things a little harder, I also want the option of including periodic boundary conditions. This just means if you walk off the finite lattice in a particular direction (say, off the left-hand side) you reappear on the opposite side of the lattice (in this case the right hand side). This means there are new connections that would look long-ranged in any planar representation of the graph, or you can think of it as putting the graph on a torus. Help with that case would be particularly appreciated.










share|improve this question

























    up vote
    4
    down vote

    favorite
    1












    I want to consider a collection of vertices arranged in a finite Hexagonal lattice, with say $n_r$ rows and $n_x$ vertices per row, for a total of $N = n_xn_r$ vertices. The goal is to construct a neighbor table, which is a matrix $A$ with dimensionality $Ntimes N$. Each element $A_ij$ is one if there is a bond connecting vertices $i$ and $j$, and zero otherwise. This can also be seen as an adjacency matrix for a particular graph.



    I can't think of a way to build this matrix that isn't frustrating to code as a function of $n_r$ and $n_x$, but I'm aware there are some lattice functions built into Mathematica. Maybe those can make the process more smooth if anyone has suggestions.



    Also, to make things a little harder, I also want the option of including periodic boundary conditions. This just means if you walk off the finite lattice in a particular direction (say, off the left-hand side) you reappear on the opposite side of the lattice (in this case the right hand side). This means there are new connections that would look long-ranged in any planar representation of the graph, or you can think of it as putting the graph on a torus. Help with that case would be particularly appreciated.










    share|improve this question























      up vote
      4
      down vote

      favorite
      1









      up vote
      4
      down vote

      favorite
      1






      1





      I want to consider a collection of vertices arranged in a finite Hexagonal lattice, with say $n_r$ rows and $n_x$ vertices per row, for a total of $N = n_xn_r$ vertices. The goal is to construct a neighbor table, which is a matrix $A$ with dimensionality $Ntimes N$. Each element $A_ij$ is one if there is a bond connecting vertices $i$ and $j$, and zero otherwise. This can also be seen as an adjacency matrix for a particular graph.



      I can't think of a way to build this matrix that isn't frustrating to code as a function of $n_r$ and $n_x$, but I'm aware there are some lattice functions built into Mathematica. Maybe those can make the process more smooth if anyone has suggestions.



      Also, to make things a little harder, I also want the option of including periodic boundary conditions. This just means if you walk off the finite lattice in a particular direction (say, off the left-hand side) you reappear on the opposite side of the lattice (in this case the right hand side). This means there are new connections that would look long-ranged in any planar representation of the graph, or you can think of it as putting the graph on a torus. Help with that case would be particularly appreciated.










      share|improve this question













      I want to consider a collection of vertices arranged in a finite Hexagonal lattice, with say $n_r$ rows and $n_x$ vertices per row, for a total of $N = n_xn_r$ vertices. The goal is to construct a neighbor table, which is a matrix $A$ with dimensionality $Ntimes N$. Each element $A_ij$ is one if there is a bond connecting vertices $i$ and $j$, and zero otherwise. This can also be seen as an adjacency matrix for a particular graph.



      I can't think of a way to build this matrix that isn't frustrating to code as a function of $n_r$ and $n_x$, but I'm aware there are some lattice functions built into Mathematica. Maybe those can make the process more smooth if anyone has suggestions.



      Also, to make things a little harder, I also want the option of including periodic boundary conditions. This just means if you walk off the finite lattice in a particular direction (say, off the left-hand side) you reappear on the opposite side of the lattice (in this case the right hand side). This means there are new connections that would look long-ranged in any planar representation of the graph, or you can think of it as putting the graph on a torus. Help with that case would be particularly appreciated.







      graphs-and-networks lattices adjacency






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked 3 hours ago









      mflynn

      1084




      1084




















          1 Answer
          1






          active

          oldest

          votes

















          up vote
          4
          down vote



          accepted










          I will take this opportunity to showcase the abilities of IGraph/M for lattice generation and mesh / graph / matrix conversions. IGraph/M thrives on user feedback, so if you find it useful, please take some time to write a few comments about you experiece. It will help me improve the package.



          Non-periodic case



          You can directly generate a (non-periodic) lattice with IGraph/M.



          << IGraphM`

          mesh = IGLatticeMesh["Hexagonal", Polygon@CirclePoints[3, 6],
          MeshCellLabel -> 2 -> "Index"]


          enter image description here



          The second argument of IGLatticeMesh may be a region. This region will be filled with cells. In this case, I chose a big hexagon to be filled with small hexagonal cells.



          The cell adjacency matrix:



          am = IGMeshCellAdjacencyMatrix[mesh, 2]


          "2" means 2-dimensional cells, i.e. little hexagons. "1" would mean edges and "0" points.



          MatrixPlot[am]


          enter image description here



          If you need the graph,



          graph = IGMeshCellAdjacencyGraph[mesh, 2, 
          VertexCoordinates -> Automatic]


          enter image description here



          Notice that this is actually a triangular connectivity, which could also be generated directly (in some shapes) with IGTriangularLattice. Demo:



          IGTriangularLattice[4], IGTriangularLattice[3, 5]


          enter image description here



          We could have use IGLatticeMesh too:



          IGLatticeMesh["Triangular", 3, 3]


          enter image description here



          Let's get the point-to-point connectivity now (instead of the cell-to-cell one):



          IGMeshCellAdjacencyGraph[%, 0]


          enter image description here



          Periodic case



          Now let us do the periodic case.



          We start with a hex lattice arrange in an $ntimes m$ grid.



          n, m = 5, 6;
          mesh = IGLatticeMesh["Hexagonal", n, m, MeshCellLabel -> 2 -> "Index"]


          enter image description here



          Convert it to a graph. This time I will not preserve the vertex coordinates so that we can get a clearer layout after we make the lattice periodic.



          graph = IGMeshCellAdjacencyGraph[mesh, 2, VertexLabels -> "Name"];
          graph = VertexReplace[graph, 2, i_ :> i]


          I have also converted the vertex names, which were of the form 2, index (2 indicating two-dimensional mesh cells) to simply index.



          enter image description here



          We add the extra edges needed for periodic boundary conditions.



          extraEdges = DeleteDuplicates@Flatten@Table[
          If[Mod[i, m] == 0, i <-> i - m + 1, i <-> Mod[i - 2 m + 1, m n, 1], ],
          If[i <= m, i <-> i + m n - m, i <-> Mod[i + m n - m + 1, m n, 1], ],
          i, m n
          ]

          pgraph = EdgeAdd[graph, extraEdges]


          Then we can get (or plot) the graph's adjacency matrix.



          IGAdjacencyMatrixPlot[pgraph]


          enter image description here



          am = AdjacencyMatrix[graph]


          Extra visualization: here's the graph in 3D with m,n = 10,20:



          (* remember to re-create graph and extraEdges after setting m,n *)
          pgraph = Graph3D[EdgeAdd[graph, extraEdges], VertexLabels -> None]


          enter image description here



          An alternative solution for the periodic case



          The adjacency relations of hexagonal cells form a triangular lattice. There is a function in IGraph/M for directly generating a triangular lattice graph, and it has an option to make it periodic:



          IGTriangularLattice[5, 10]


          enter image description here



          IGTriangularLattice[5, 10, "Periodic" -> True]


          enter image description here



          Then you can just get the adjacency matrix again.



          Note that the m,n syntax in IGLatticeMesh and IGTriangularLattice do not have the exact same meaning—pay attention to the difference if you mix these approaches! The vertex labelling will also be different. Presumably at some point you will want to use the visualization of the hex lattice mesh to plot your results. Thus it is useful to be able to map back to mesh cell indices.






          share|improve this answer






















            Your Answer




            StackExchange.ifUsing("editor", function ()
            return StackExchange.using("mathjaxEditing", function ()
            StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix)
            StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["$", "$"], ["\\(","\\)"]]);
            );
            );
            , "mathjax-editing");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "387"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184792%2fhow-to-build-a-neighbor-table-for-the-hexagonal-lattice%23new-answer', 'question_page');

            );

            Post as a guest






























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            4
            down vote



            accepted










            I will take this opportunity to showcase the abilities of IGraph/M for lattice generation and mesh / graph / matrix conversions. IGraph/M thrives on user feedback, so if you find it useful, please take some time to write a few comments about you experiece. It will help me improve the package.



            Non-periodic case



            You can directly generate a (non-periodic) lattice with IGraph/M.



            << IGraphM`

            mesh = IGLatticeMesh["Hexagonal", Polygon@CirclePoints[3, 6],
            MeshCellLabel -> 2 -> "Index"]


            enter image description here



            The second argument of IGLatticeMesh may be a region. This region will be filled with cells. In this case, I chose a big hexagon to be filled with small hexagonal cells.



            The cell adjacency matrix:



            am = IGMeshCellAdjacencyMatrix[mesh, 2]


            "2" means 2-dimensional cells, i.e. little hexagons. "1" would mean edges and "0" points.



            MatrixPlot[am]


            enter image description here



            If you need the graph,



            graph = IGMeshCellAdjacencyGraph[mesh, 2, 
            VertexCoordinates -> Automatic]


            enter image description here



            Notice that this is actually a triangular connectivity, which could also be generated directly (in some shapes) with IGTriangularLattice. Demo:



            IGTriangularLattice[4], IGTriangularLattice[3, 5]


            enter image description here



            We could have use IGLatticeMesh too:



            IGLatticeMesh["Triangular", 3, 3]


            enter image description here



            Let's get the point-to-point connectivity now (instead of the cell-to-cell one):



            IGMeshCellAdjacencyGraph[%, 0]


            enter image description here



            Periodic case



            Now let us do the periodic case.



            We start with a hex lattice arrange in an $ntimes m$ grid.



            n, m = 5, 6;
            mesh = IGLatticeMesh["Hexagonal", n, m, MeshCellLabel -> 2 -> "Index"]


            enter image description here



            Convert it to a graph. This time I will not preserve the vertex coordinates so that we can get a clearer layout after we make the lattice periodic.



            graph = IGMeshCellAdjacencyGraph[mesh, 2, VertexLabels -> "Name"];
            graph = VertexReplace[graph, 2, i_ :> i]


            I have also converted the vertex names, which were of the form 2, index (2 indicating two-dimensional mesh cells) to simply index.



            enter image description here



            We add the extra edges needed for periodic boundary conditions.



            extraEdges = DeleteDuplicates@Flatten@Table[
            If[Mod[i, m] == 0, i <-> i - m + 1, i <-> Mod[i - 2 m + 1, m n, 1], ],
            If[i <= m, i <-> i + m n - m, i <-> Mod[i + m n - m + 1, m n, 1], ],
            i, m n
            ]

            pgraph = EdgeAdd[graph, extraEdges]


            Then we can get (or plot) the graph's adjacency matrix.



            IGAdjacencyMatrixPlot[pgraph]


            enter image description here



            am = AdjacencyMatrix[graph]


            Extra visualization: here's the graph in 3D with m,n = 10,20:



            (* remember to re-create graph and extraEdges after setting m,n *)
            pgraph = Graph3D[EdgeAdd[graph, extraEdges], VertexLabels -> None]


            enter image description here



            An alternative solution for the periodic case



            The adjacency relations of hexagonal cells form a triangular lattice. There is a function in IGraph/M for directly generating a triangular lattice graph, and it has an option to make it periodic:



            IGTriangularLattice[5, 10]


            enter image description here



            IGTriangularLattice[5, 10, "Periodic" -> True]


            enter image description here



            Then you can just get the adjacency matrix again.



            Note that the m,n syntax in IGLatticeMesh and IGTriangularLattice do not have the exact same meaning—pay attention to the difference if you mix these approaches! The vertex labelling will also be different. Presumably at some point you will want to use the visualization of the hex lattice mesh to plot your results. Thus it is useful to be able to map back to mesh cell indices.






            share|improve this answer


























              up vote
              4
              down vote



              accepted










              I will take this opportunity to showcase the abilities of IGraph/M for lattice generation and mesh / graph / matrix conversions. IGraph/M thrives on user feedback, so if you find it useful, please take some time to write a few comments about you experiece. It will help me improve the package.



              Non-periodic case



              You can directly generate a (non-periodic) lattice with IGraph/M.



              << IGraphM`

              mesh = IGLatticeMesh["Hexagonal", Polygon@CirclePoints[3, 6],
              MeshCellLabel -> 2 -> "Index"]


              enter image description here



              The second argument of IGLatticeMesh may be a region. This region will be filled with cells. In this case, I chose a big hexagon to be filled with small hexagonal cells.



              The cell adjacency matrix:



              am = IGMeshCellAdjacencyMatrix[mesh, 2]


              "2" means 2-dimensional cells, i.e. little hexagons. "1" would mean edges and "0" points.



              MatrixPlot[am]


              enter image description here



              If you need the graph,



              graph = IGMeshCellAdjacencyGraph[mesh, 2, 
              VertexCoordinates -> Automatic]


              enter image description here



              Notice that this is actually a triangular connectivity, which could also be generated directly (in some shapes) with IGTriangularLattice. Demo:



              IGTriangularLattice[4], IGTriangularLattice[3, 5]


              enter image description here



              We could have use IGLatticeMesh too:



              IGLatticeMesh["Triangular", 3, 3]


              enter image description here



              Let's get the point-to-point connectivity now (instead of the cell-to-cell one):



              IGMeshCellAdjacencyGraph[%, 0]


              enter image description here



              Periodic case



              Now let us do the periodic case.



              We start with a hex lattice arrange in an $ntimes m$ grid.



              n, m = 5, 6;
              mesh = IGLatticeMesh["Hexagonal", n, m, MeshCellLabel -> 2 -> "Index"]


              enter image description here



              Convert it to a graph. This time I will not preserve the vertex coordinates so that we can get a clearer layout after we make the lattice periodic.



              graph = IGMeshCellAdjacencyGraph[mesh, 2, VertexLabels -> "Name"];
              graph = VertexReplace[graph, 2, i_ :> i]


              I have also converted the vertex names, which were of the form 2, index (2 indicating two-dimensional mesh cells) to simply index.



              enter image description here



              We add the extra edges needed for periodic boundary conditions.



              extraEdges = DeleteDuplicates@Flatten@Table[
              If[Mod[i, m] == 0, i <-> i - m + 1, i <-> Mod[i - 2 m + 1, m n, 1], ],
              If[i <= m, i <-> i + m n - m, i <-> Mod[i + m n - m + 1, m n, 1], ],
              i, m n
              ]

              pgraph = EdgeAdd[graph, extraEdges]


              Then we can get (or plot) the graph's adjacency matrix.



              IGAdjacencyMatrixPlot[pgraph]


              enter image description here



              am = AdjacencyMatrix[graph]


              Extra visualization: here's the graph in 3D with m,n = 10,20:



              (* remember to re-create graph and extraEdges after setting m,n *)
              pgraph = Graph3D[EdgeAdd[graph, extraEdges], VertexLabels -> None]


              enter image description here



              An alternative solution for the periodic case



              The adjacency relations of hexagonal cells form a triangular lattice. There is a function in IGraph/M for directly generating a triangular lattice graph, and it has an option to make it periodic:



              IGTriangularLattice[5, 10]


              enter image description here



              IGTriangularLattice[5, 10, "Periodic" -> True]


              enter image description here



              Then you can just get the adjacency matrix again.



              Note that the m,n syntax in IGLatticeMesh and IGTriangularLattice do not have the exact same meaning—pay attention to the difference if you mix these approaches! The vertex labelling will also be different. Presumably at some point you will want to use the visualization of the hex lattice mesh to plot your results. Thus it is useful to be able to map back to mesh cell indices.






              share|improve this answer
























                up vote
                4
                down vote



                accepted







                up vote
                4
                down vote



                accepted






                I will take this opportunity to showcase the abilities of IGraph/M for lattice generation and mesh / graph / matrix conversions. IGraph/M thrives on user feedback, so if you find it useful, please take some time to write a few comments about you experiece. It will help me improve the package.



                Non-periodic case



                You can directly generate a (non-periodic) lattice with IGraph/M.



                << IGraphM`

                mesh = IGLatticeMesh["Hexagonal", Polygon@CirclePoints[3, 6],
                MeshCellLabel -> 2 -> "Index"]


                enter image description here



                The second argument of IGLatticeMesh may be a region. This region will be filled with cells. In this case, I chose a big hexagon to be filled with small hexagonal cells.



                The cell adjacency matrix:



                am = IGMeshCellAdjacencyMatrix[mesh, 2]


                "2" means 2-dimensional cells, i.e. little hexagons. "1" would mean edges and "0" points.



                MatrixPlot[am]


                enter image description here



                If you need the graph,



                graph = IGMeshCellAdjacencyGraph[mesh, 2, 
                VertexCoordinates -> Automatic]


                enter image description here



                Notice that this is actually a triangular connectivity, which could also be generated directly (in some shapes) with IGTriangularLattice. Demo:



                IGTriangularLattice[4], IGTriangularLattice[3, 5]


                enter image description here



                We could have use IGLatticeMesh too:



                IGLatticeMesh["Triangular", 3, 3]


                enter image description here



                Let's get the point-to-point connectivity now (instead of the cell-to-cell one):



                IGMeshCellAdjacencyGraph[%, 0]


                enter image description here



                Periodic case



                Now let us do the periodic case.



                We start with a hex lattice arrange in an $ntimes m$ grid.



                n, m = 5, 6;
                mesh = IGLatticeMesh["Hexagonal", n, m, MeshCellLabel -> 2 -> "Index"]


                enter image description here



                Convert it to a graph. This time I will not preserve the vertex coordinates so that we can get a clearer layout after we make the lattice periodic.



                graph = IGMeshCellAdjacencyGraph[mesh, 2, VertexLabels -> "Name"];
                graph = VertexReplace[graph, 2, i_ :> i]


                I have also converted the vertex names, which were of the form 2, index (2 indicating two-dimensional mesh cells) to simply index.



                enter image description here



                We add the extra edges needed for periodic boundary conditions.



                extraEdges = DeleteDuplicates@Flatten@Table[
                If[Mod[i, m] == 0, i <-> i - m + 1, i <-> Mod[i - 2 m + 1, m n, 1], ],
                If[i <= m, i <-> i + m n - m, i <-> Mod[i + m n - m + 1, m n, 1], ],
                i, m n
                ]

                pgraph = EdgeAdd[graph, extraEdges]


                Then we can get (or plot) the graph's adjacency matrix.



                IGAdjacencyMatrixPlot[pgraph]


                enter image description here



                am = AdjacencyMatrix[graph]


                Extra visualization: here's the graph in 3D with m,n = 10,20:



                (* remember to re-create graph and extraEdges after setting m,n *)
                pgraph = Graph3D[EdgeAdd[graph, extraEdges], VertexLabels -> None]


                enter image description here



                An alternative solution for the periodic case



                The adjacency relations of hexagonal cells form a triangular lattice. There is a function in IGraph/M for directly generating a triangular lattice graph, and it has an option to make it periodic:



                IGTriangularLattice[5, 10]


                enter image description here



                IGTriangularLattice[5, 10, "Periodic" -> True]


                enter image description here



                Then you can just get the adjacency matrix again.



                Note that the m,n syntax in IGLatticeMesh and IGTriangularLattice do not have the exact same meaning—pay attention to the difference if you mix these approaches! The vertex labelling will also be different. Presumably at some point you will want to use the visualization of the hex lattice mesh to plot your results. Thus it is useful to be able to map back to mesh cell indices.






                share|improve this answer














                I will take this opportunity to showcase the abilities of IGraph/M for lattice generation and mesh / graph / matrix conversions. IGraph/M thrives on user feedback, so if you find it useful, please take some time to write a few comments about you experiece. It will help me improve the package.



                Non-periodic case



                You can directly generate a (non-periodic) lattice with IGraph/M.



                << IGraphM`

                mesh = IGLatticeMesh["Hexagonal", Polygon@CirclePoints[3, 6],
                MeshCellLabel -> 2 -> "Index"]


                enter image description here



                The second argument of IGLatticeMesh may be a region. This region will be filled with cells. In this case, I chose a big hexagon to be filled with small hexagonal cells.



                The cell adjacency matrix:



                am = IGMeshCellAdjacencyMatrix[mesh, 2]


                "2" means 2-dimensional cells, i.e. little hexagons. "1" would mean edges and "0" points.



                MatrixPlot[am]


                enter image description here



                If you need the graph,



                graph = IGMeshCellAdjacencyGraph[mesh, 2, 
                VertexCoordinates -> Automatic]


                enter image description here



                Notice that this is actually a triangular connectivity, which could also be generated directly (in some shapes) with IGTriangularLattice. Demo:



                IGTriangularLattice[4], IGTriangularLattice[3, 5]


                enter image description here



                We could have use IGLatticeMesh too:



                IGLatticeMesh["Triangular", 3, 3]


                enter image description here



                Let's get the point-to-point connectivity now (instead of the cell-to-cell one):



                IGMeshCellAdjacencyGraph[%, 0]


                enter image description here



                Periodic case



                Now let us do the periodic case.



                We start with a hex lattice arrange in an $ntimes m$ grid.



                n, m = 5, 6;
                mesh = IGLatticeMesh["Hexagonal", n, m, MeshCellLabel -> 2 -> "Index"]


                enter image description here



                Convert it to a graph. This time I will not preserve the vertex coordinates so that we can get a clearer layout after we make the lattice periodic.



                graph = IGMeshCellAdjacencyGraph[mesh, 2, VertexLabels -> "Name"];
                graph = VertexReplace[graph, 2, i_ :> i]


                I have also converted the vertex names, which were of the form 2, index (2 indicating two-dimensional mesh cells) to simply index.



                enter image description here



                We add the extra edges needed for periodic boundary conditions.



                extraEdges = DeleteDuplicates@Flatten@Table[
                If[Mod[i, m] == 0, i <-> i - m + 1, i <-> Mod[i - 2 m + 1, m n, 1], ],
                If[i <= m, i <-> i + m n - m, i <-> Mod[i + m n - m + 1, m n, 1], ],
                i, m n
                ]

                pgraph = EdgeAdd[graph, extraEdges]


                Then we can get (or plot) the graph's adjacency matrix.



                IGAdjacencyMatrixPlot[pgraph]


                enter image description here



                am = AdjacencyMatrix[graph]


                Extra visualization: here's the graph in 3D with m,n = 10,20:



                (* remember to re-create graph and extraEdges after setting m,n *)
                pgraph = Graph3D[EdgeAdd[graph, extraEdges], VertexLabels -> None]


                enter image description here



                An alternative solution for the periodic case



                The adjacency relations of hexagonal cells form a triangular lattice. There is a function in IGraph/M for directly generating a triangular lattice graph, and it has an option to make it periodic:



                IGTriangularLattice[5, 10]


                enter image description here



                IGTriangularLattice[5, 10, "Periodic" -> True]


                enter image description here



                Then you can just get the adjacency matrix again.



                Note that the m,n syntax in IGLatticeMesh and IGTriangularLattice do not have the exact same meaning—pay attention to the difference if you mix these approaches! The vertex labelling will also be different. Presumably at some point you will want to use the visualization of the hex lattice mesh to plot your results. Thus it is useful to be able to map back to mesh cell indices.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 15 mins ago

























                answered 57 mins ago









                Szabolcs

                155k13419909




                155k13419909



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmathematica.stackexchange.com%2fquestions%2f184792%2fhow-to-build-a-neighbor-table-for-the-hexagonal-lattice%23new-answer', 'question_page');

                    );

                    Post as a guest













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    List of Gilmore Girls characters

                    Confectionery