.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "auto_examples/algorithms/plot_largest_component.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_algorithms_plot_largest_component.py: =========================== Largest connected component =========================== Compute and draw the largest connected component. .. GENERATED FROM PYTHON SOURCE LINES 8-26 .. image-sg:: /auto_examples/algorithms/images/sphx_glr_plot_largest_component_001.png :alt: plot largest component :srcset: /auto_examples/algorithms/images/sphx_glr_plot_largest_component_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.pyplot as plt import xgi # generate hypergraph seed = 12 H = xgi.fast_random_hypergraph(20, [0.05, 0.01], seed=seed) # compute the largest component hypergraph H_gcc = xgi.largest_connected_hypergraph(H) # draw hypergraph pos = xgi.barycenter_spring_layout(H, seed=seed) xgi.draw(H, pos=pos) xgi.draw(H_gcc, pos=pos, node_fc="r", edge_fc="r", dyad_color="r") plt.show() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.026 seconds) .. _sphx_glr_download_auto_examples_algorithms_plot_largest_component.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_largest_component.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_largest_component.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_largest_component.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_