.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/layouts/plot_triangular_lattice.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code. .. rst-class:: sphx-glr-example-title .. _sphx_glr_auto_examples_layouts_plot_triangular_lattice.py: ======================= Triangular lattice ======================= Draw triangular lattice. .. GENERATED FROM PYTHON SOURCE LINES 8-32 .. image-sg:: /auto_examples/layouts/images/sphx_glr_plot_triangular_lattice_001.png :alt: plot triangular lattice :srcset: /auto_examples/layouts/images/sphx_glr_plot_triangular_lattice_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import networkx as nx import xgi # generate lattice m, n = 5, 10 # lattice dimensions p = 0.5 # probability to promote 3-clique to 2-simplex G = nx.triangular_lattice_graph(m, n, with_positions=True) pos = nx.get_node_attributes(G, "pos") mapping = {i: list(G.nodes)[i] for i in range(0, len(list(G.nodes)))} inv_mapping = {v: k for k, v in mapping.items()} G_aux = nx.relabel_nodes(G, inv_mapping) S = xgi.flag_complex_d2(G_aux, p2=p) # draw lattice pos = {inv_mapping[k]: v for k, v in pos.items()} xgi.draw(S, pos=pos) plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.031 seconds) .. _sphx_glr_download_auto_examples_layouts_plot_triangular_lattice.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_triangular_lattice.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_triangular_lattice.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_triangular_lattice.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_